Accessing thermo variables (ix, xu, ...) from python

I am running LAMMPS via the Python library and that is going fine. However, I need access to the unwrapped coordinates and box image thermo variables (ix/y/z and x/y/zu), but these seem not to be there. Plain coordinates on the other hand are accessible with lammps_instance.lmp.numpy.extract_atom("x").
I checked if I could write ix and the like to a dump file, and that works normally…
How can I extract the desired variables? Thanks in advance!

The simulation is a simple LJ diffusion example, see below:

variable thermo equal 100
variable duration equal 500
variable L equal 15
variable Lhalf equal $(0.5*v_L)
variable thickness equal 2.0
 
units lj
atom_style atomic
lattice fcc 0.5
 
# Create regions to place atoms
variable left equal 0.5*$L-0.5*${thickness}
variable right equal 0.5*$L+0.5*${thickness}
region system block 0 $L 0 $L 0 ${Lhalf}
region boxinside block ${left} ${right} 0 $L 0 ${Lhalf}
region boxoutside block ${left} ${right} 0 $L 0 ${Lhalf} side out
 
# Create a box with 2 atom types in the region system
create_box 2 system
# Create atoms of type 1 inside the inner region
create_atoms 1 region boxinside
# Create atoms of type 2 inside the outer region
create_atoms 2 region boxoutside
 
# Set atom masses 
mass 1 1.0
mass 2 4.0
 
# Give initial velocity, T=3.00, seed = 1337
velocity all create 3.00 1337 loop geom
 
# Choose LJ with 2.5sigma cutoff
pair_style lj/cut 2.5
pair_coeff * * 1.0 1.0 2.5
neigh_modify every 1 delay 0 check yes
 
# Create two groups for computing diffusion coefficients
group light type 1
group heavy type 2
 
# Measure mean square displacement and diffusion coefficient
compute msd_light light msd com yes
variable diffusion_coeff_light equal c_msd_light[4]/6/(step*dt+1.0e-6)
variable msd_light equal c_msd_light[4]
 
compute msd_heavy heavy msd com yes
variable msd_heavy equal c_msd_heavy[4]
variable diffusion_coeff_heavy equal c_msd_heavy[4]/6/(step*dt+1.0e-6)

thermo ${thermo}
thermo_style custom step v_diffusion_coeff_light v_msd_light v_diffusion_coeff_heavy v_msd_heavy
fix 1 all nve
compute displace all displace/atom

(LAMMPS version 27Jun2024, Python 3.10.12)

You can’t get those from lammps_extract_atom() because those are not what is stored with atoms but rather they are computed on-the-fly. You can get access to “computed” properties with compute property/atom or fix store/state instead.

BTW: these are not “thermo variables” but per-atom properties.

Thanks! With your help, I was able to get it running.

For reference, if anyone finds this having a similar issue, here are the commands that work for me:
In the LAMMPS input: compute compute_ix all property/atom ix iy iz
in the Python script: ix = self.lmp.numpy.extract_compute("compute_ix", LMP_STYLE_ATOM, LMP_TYPE_ARRAY)
(don’t forget to from lammps import LMP_STYLE_ATOM, LMP_TYPE_ARRAY)