Dear Axel
thanks for reply,
about your 7th answer : my y and z component of electric field will get undefined when y and z become both zero .there are some terms like y/sqrt(y^2+ z^2) and I want to put them equal to zeros.that’s my problem how to avoid them become zero.
Best
I want to define an electric field consisted of two parts:
variable p2 atom “y^2+z^2”
if "p2 = 0 " then “fix h a efield v_Ex 0 0”
else &
“fix h a efield v_Ex v_Ey v_Ez”
so I have two different fields,I already know that I can’t use v_x in if command and it should be as $x but I can’t use $x in atom style
this is wrong and confusing on so many levels, i don’t really know where to begin:
on ‘if “p2 = 0”’ :
-
“=” is not for comparing equality, “==” is.
-
you are comparing strings, p2 is not referring to the p2 variable
-
it is a very bad idea to compare floating point numbers (which is what v_p2 would evaluate to) for equality due to the idiosyncrasies of floating point math
-
the if statement is a global comparison that is only evaluated when the input line is processed, so it doesn’t make sense to use a variable that may change later
-
the purpose of the if statement is apparently, apply one fix definition to all atoms when the condition is true and the other fix to atoms when the condition is false. that is not how LAMMPS works. the fix commands creates a global instance of the fix. you can select which atoms it applies to via groups. using the if statement this way is against the entire logic of LAMMPS scripting.
-
this is implied in the previous point, but it makes not sense at all to use an atom style variable in a global context.
on using two different fields:
- it is not clear whether you want to decide which atoms to assign the two fields dynamically during the run or is this a one time choice. the latter case is easy to handle: define two groups, define two fixes each working on one of the two groups. the former case is a bad idea. you’ll having a step function in the force which will result in all kinds of artefacts, e.g. density anomalies around the singularity.
8) of course, if you absolutely insist, you can implement this kind of thing in LAMMPS, and you only need one fix for it, as you can use boolean expressions in atom and equal style variables. they will evaluate to either 0.0 or 1.0 depending on whether the expression is false or true. so just multiplying an optional component with the boolean expression with turn it on or off automatically.
on “$x vs v_x”:
- i honestly don’t understand what you mean by this, but since you have pretty much misunderstood everything else related to what you quoted as script code, it is safe to assume that you are misunderstanding something here as well.
pls help me.
you have to help yourself first. and a lot. from what you present, you have to reread the documentation with much more care and revisit all the details that you have misunderstood. you obviously are trying something that is far too advanced for you level of understanding. that is bound to send you on the road to frustration, confusion and ultimately doom.
axel.