I want to use the Shake command to fix carbon and aluminum atoms, but it doesn’t work.
The error now looks like this:
ERROR: Cannot use fix shake with non-molecular system (…/fix_shake.cpp:74)
in file:
units metal
boundary p p p
atom_style atomic
atom_modify map yes
read_data lammps.dat
group sub id 14 55
pair_style nnp
pair_coeff * * ffield.sannp eatom zero Si Cr C Al
velocity all create 1873.0 15180
dump Dump all custom 1 tmpdir/lammps.dmp type x y z
thermo_style custom step time cpu pe ke etotal enthalpy temp press vol density cella cellb cellc cellalpha cellbeta cellgamma
thermo 1
fix ensemble all nvt temp 1873.0 1873.0 2.0
fix Cbond sub shake 0.0001 100 0 t 3 4
1 28.085500000 # Si
2 51.991610000 # Cr
3 12.010700000 # C
4 26.981540000 # Al
Do I need to use a molecule file?
I created this file but could not load it successfully.
ERROR: No atoms or invalid atom count in molecule file (…/molecule.cpp:504)
Added molecule command under read_data command.
molecule 1 C-Al.txt
That is because you are misunderstanding what fix shake does and how the SHAKE algorithm works. There are some detailed explanations in the LAMMPS manual, but you seem to have chosen to ignore those. It is also explained in great detail in text books on molecular dynamics simulations.
Bottom line: fix shake works on explicit bonds (like in molecular force fields) and applies a constraint to maintain the bond length (and for groups of three atoms that form a triangle, also the angle can be constrained). This requires defining bonds in the topology and than in turn requires a different atom style. However, your system seems to be using a machine learning potential (albeit not one included in the official LAMMPS distribution) and in those all bonds are implicit.
It is not a good idea to use the verb “to fix” in this context since a) LAMMPS has a “fix” command and b) the verb “to fix” can have rather different meanings (e.g. to repair, or to attach in addition to to fixate or to affix or to immobilize). Often people mean to immobilize and fix shake is definitely the wrong command to immobilize atoms in LAMMPS. I suggest you search the forum archives (or with google or equivalent) for discussions on how to “immobilize atoms” in LAMMPS, e.g. by excluding them from time integration or by setting their velocities and forces to zero.
If you want to immobilize some atoms, why integrate their equations of motion and monitor and adjust their temperature. This is inconsistent.
No that won’t help.
That is because your molecule file does not follow the format as described in the manual. The first line is ignored. In your file it says “2 atoms” and thus you get an error about “No atoms” since there is no statement about the number of atoms in a line that is being read. Furthermore, the syntax of the various sections is not correct (there must be an empty line following each header) and the Bonds section’s content is not correct either. Also, there must not be a Masses section for a system where there are no per-atom masses, but the atomic masses are tied to that atom type.
Besides, the same limitation that I mentioned above applies to molecule files. You cannot create bonds for a system that has no provisions for adding explicit bonds.
Overall, you need to pay much more attention to the documentation. All that I have pointed out, is explained in detail in the documentation. You have to follow it carefully.
I ended up writing “fixing the atoms,” but the correct answer is “fixing the distance between atoms.”
Sorry for writing it wrong.
I haven’t learned enough yet and thought that only the Shake command could be used in this case. Are there any other commands I can use?
Constrain which distances between which pairs of atoms at which distance?
In a general crystal structure with multiple atoms of multiple types, the result constraining all distances between all pairs is typically identical with immobilizing those atoms due to symmetry.
The fix shake command requires bonds to know which pairs of atoms and the equilibrium distance of the corresponding bond potential provides the constraint distance. In your system such information does not exist.
I would like to fix the 14th carbon atom and the 55th aluminum atom with an interatomic distance of 1.96 Å out of 55 atoms. Below is the atomic coordinate data.
Again, please do not use the verb “to fix” in the context of LAMMPS. In this case the better term is to constrain. Also, if you have only 55 atoms in total and have multiple atom types, you cannot have a 55th carbon atom, but only the 55th atom (which will be a carbon). In fact, I only see one atom of type 3 and type 4 each (which would be carbon and aluminum, respectively, according to your original post).
You have three options:
define a group (e.g. with group onebond id 14 55) and then use fix rigid with the “group onebond” option to select the group of atoms to keep rigid. Please note that this is not compatible with minimizations (fix rigid is not applied in that case).
change the atom style (and the data file correspondingly) so that you define a bond between those two atoms (e.g. using bond style zero). Then you will need to use special_bonds lj/coul 1.0 1.0 1.0 to make certain there are no exclusions applied to the non-bonded interactions. And then you can apply fix shake based on the bond type (that would be bond type 1, since you will have only one bond and thus only one bond type).
use fix restrain to add a restraining force between those two atoms. This will not keep the distance fixed, but close to the desired distance in accord with the selected force constant. Please note, that using a very large force constant (to make it a stiff restraint) will require using a shorter timestep.