Run time error: arccos of invalid value in variable formula (../variable.cpp:3373)

dear Lammps users, I’m trying to simulate the compression test on my atomic box and then extract stress-strain data to plotting them. I’m facing the mentioned error in topic while running this program:
units metal
echo both
atom_style atomic
dimension 3
boundary s p s
read_restart restart.rejuvenated&relaxed10(10)
timestep 0.002
pair_style eam/alloy
pair_coeff * * CuZrAl.eam.eam Zr Cu Al

energy minimization
minimize 1.0e-9 1.0e-6 1000 1000
compute 1 all stress/atom NULL
compute csym all centro/atom fcc
compute peratom all pe/atom
variable tmp equal ly
variable lo equal ${tmp}
variable strain equal (ly-v_lo)/v_lo
variable p1 equal “-pxx/10000”
variable p2 equal “-pyy/10000”
variable p3 equal “-pzz/10000”
variable p12 equal “-pxy/10000”
variable p23 equal “-pyz/10000”
variable p13 equal “-pxz/10000”
variable fm equal “(v_p1+v_p2+v_p3)/3” #hydrostatic stress
variable fv equal “sqrt(((v_p2-v_p3)^2+(v_p3-Vp1)^2+(v_p1-v_p2)^2+6*(v_p12^2+v_p23^2+v_p13^2))/2)” #von misess stress
variable t equal “v_fm/v_fv”
variable fd equal (((v_p1-v_fm)(v_p2-v_fm)(v_p3-v_fm))-(v_p12)^2*(v_p3-v_fm)-(v_p13)^2*(v_p2-v_fm)-(v_p23)^2(v_p1-v_fm)+2v_p12v_p23*v_p13)#deviatoric von misess stress

#principal stresses
variable I1 equal “(v_p1+v_p2+v_p3)”
variable I2 equal “((v_p1)(v_p2))+((v_p2)(v_p3))+((v_p1)(v_p3))-(v_p12)^2-(v_p23)^2-(v_p13)^2"
variable I3 equal "((v_p1)
(v_p2)(v_p3))-((v_p1)((v_p23)^2))-((v_p2)((v_p13)^2))-((v_p3)((v_p12)^2))+2*(v_p12)(v_p23)(v_p13)”
variable A equal “(acos(((2v_I1)^3)-9(v_I1)(v_I2)+27(v_I3))/(2*((v_I1)^2-(3*(v_I2)))^(3/2))))/3”
variable s1 equal “((v_I1)/3)+(2/3)(sqrt((v_I1)^2-(3(v_I2))))cos(v_A)"
variable s2 equal "((v_I1)/3)+(2/3)
(sqrt((v_I1)^2-(3*(v_I2))))cos(v_A)-(2PI)/3)”
variable s3 equal “((v_I1)/3)+(2/3)(sqrt((v_I1)^2-(3(v_I2))))cos(v_A)-(4PI)/3)”

thermo 10000
thermo_style custom step temp vol press pe ke etotal
dump 1 all custom 10000 tension_CuZrAl.lammpstrj id
dump 2 all cfg 10000 dump.tensile_CuZrAl*.cfg mass type xs ys zs c_csym c_peratom
dump 3 all custom 10000 stress_peratom.*id type c_1[1] c_1[2] c_1[3] c_1[4] c_1[5] c_1[6]

log NVTlog46468_compressure_CuZrAl.data
velocity all create 300 8175447 rot yes mom yes dist gaussian

#temperature controller
fix 1 all nvt temp 300 300 0.1

#tensile deformation
fix 2 all deform 1 y erate -0.00001 units box
fix 3 all print 10000 “{strain} {p2}” file stress_strain_data.txt

run 1000000

run time error is: Arccos of invalid value in variable formula (…/variable.cpp:3373)
please guide me to solve it

Hey Marya,

The problem should be due to you ending up with an input value for the acos() function that lies outside the range [-1,1]. Maybe there is something wrong in the formulas you are using that leads to such a thing to happen (this you can verify). Or, if you really cannot find any mistakes in the formulas you are using, maybe it is some floating error. I dont know if it really can be the latter, but if it can, maybe there is some pre-established function in LAMMPS that could help you tackle the issue (like the int() of python) - although then you would need to set up a condition to call such a function only when you have an argument that is smaller than - 1 or larger than 1 (which I dont know if is indeed possible).

Your input file is not correctly quoted (just look at it, does it look correct to you?) and thus very hard to read. Please have a close look at this post and follow its guidelines and suggestions more closely. It also explains how to correctly quote text so that the forum software will not interpret special characters a markup for formatting.

You appear to be doing some rather complex math. Have you checked that all intermediate results are within the necessary ranges to lead to valid results? According to the error message that does not seem to be the case.