Dear Lammps user,
I want to use fix atom/swap command to swap Zr and Y atoms from time to time. However, I’ve got this error:
ERROR: All atoms of a swapped type must have same charge. (…/fix_atom_swap.cpp:259)
The charge of my atoms of same type is the same. I don’t know why this is happening. I copied my script at the end.
Also I had a look at the source code in fix_atom_swap.cpp, in if (atom->q_flag && !semi_grand_flag) section, here is my understanding: as soon as one atom is found in the defined group and swap type, the charge of this swap type is assigned, and “first” variable becomes to 0. Then the rest atoms of the same swap type will compare to the charge value. I’m confused on these two commands:
if (first) qtype[iswaptype] = -DBL_MAX;
MPI_Allreduce(&qtype[iswaptype],&qmax,1,MPI_DOUBLE,MPI_MAX,world);
if (first) qtype[iswaptype] = DBL_MAX;
MPI_Allreduce(&qtype[iswaptype],&qmin,1,MPI_DOUBLE,MPI_MIN,world);
What's the value of qmax and qmin? why make qtype equal to -DBL_MAX and DBL_MAX?Thank you so much for your help!
---------- Initialize Simulation ---------------------
clear
units metal
dimension 3
boundary p p p
atom_style full
---------- Create Atomistic Structure ---------------------
kspace_style ewald 1.0e-8
pair_style buck/coul/long 10
read_data end300K1500K.dat
group oxygen type 1
group zirco type 2
group yttria type 3
group cation union zirco yttria
set type 2 charge 4
set type 1 charge -2
set type 3 charge 3
---------- Define Interatomic Potential ---------------------
pair_coeff 2 2 0 10 0 10
pair_coeff 1 1 13098.9 0.219670 49.2998 10
pair_coeff 1 2 1292.85 0.358388 19.3646 10
pair_coeff 2 3 0 10 0 10
pair_coeff 1 3 1642.724 0.353197 104.180 10
pair_coeff 3 3 0 10 0 10
#-----------NVT simulation 1500K---------------
reset_timestep 0
timestep 0.001
thermo_style custom step etotal pe temp press lx ly lz pxx pyy pzz
fix 4 all nvt temp 1500 1500 0.1
fix 5 cation atom/swap 20 10000 5829017 1500 types 2 3
thermo 2000
run 200000