about harmonic bonds

Dear all,

I have implemented a variant of the harmonic bond that is anisotropic, with different equilibrium distances in the three different directions. Now I want to vary the equilibrium distance in space. I have tried to define different groups with different lengths but gives me the error:

ERROR: All bond coeffs are not set

I’m not sure what’s the best way to go.

Thanks,
Enrique

Bond styles (as well as pair, angle, dihedral, etc) all define coeffs
based on “types”, not groups. So if you have N bond types
you have to define N bond coeffs. However it is up to you
what arguments to include in a bond_coeff command or how
they are used inside the bond potential. So you could specify
commands like

bond_style harmonic/new arg1 arg2 …
bond_coeff * carg1 carg2 carg3 …

And the argN and cargN can be anything you like. E.g. they
could be per-atom variable names that let you define a formula
that varies spatially with the coords of the atoms in the bond.

The “*” will satisfy LAMMPS that bond coeffs have been defined
for all bond types.

Steve

I’m sure I’m doing something stupid but I can’t make it to work. Even with bond_harmonic I don’t see where the code substitutes the variable. I am attaching a small input file that reproduces the error.
I’m using 17 Dec 2016 version.
Maybe you meant that the variable substitution should be implemented.

Thanks,
Enrique

in.bond-test (1.89 KB)

ATT00001.htm (5.09 KB)

I’m sure I’m doing something stupid but I can’t make it to work. Even with
bond_harmonic I don’t see where the code substitutes the variable. I am
attaching a small input file that reproduces the error.

there are two issues.
1) you are trying to use '//' to comment out a line. that is not
supported. the comment character in LAMMPS is '#'
2) you are trying to expand an atom style variable in the input. that
is not supported and doesn't make sense. you need a variable that
evaluates to a global value (equal style, index style, python style,
string style).

what you are trying to do is illogical. bonds in LAMMPS are explicit
and not related to per-atom properties.

axel.

I’m not sure how compatible is your answer with Steve’s but in any case, why can’t I define a type of bond between 2 groups of atoms? And do that for as many groups as I want? There is something about the definition of a bond that I am not understanding, I guess.

Thanks,

I’m not sure how compatible is your answer with Steve’s but in any case,
why can’t I define a type of bond between 2 groups of atoms? And do that
for as many groups as I want?

​my answer is 100% compatible with steve's​

​bond types are assigned to bonds, not atoms.​ if you want a particular set
of coefficients to be assigned to bonds between two groups of atoms, you
will have to suitably create/define those bonds so they have a unique type
and then assign the parameters to that bond type. this is all very logical
and straightforward. what you are asking for to do directly is very unusual
instead.basically, you want to do things backwards. it *can* be realized,
but that requires that you write your own code that matches bond parameters
for individual bonds from some kind of table based on atom IDs. this is far
from trivial, and as steve indicated, that would make the individual bond
type assignment irrelevant (hence the '*').

There is something about the definition of a bond that I am not
understanding, I guess.


LAMMPS uses the same kind of bond topology definition and bond type
parameter assignment than most classical MD codes have.
please have a closer look at the documentation of data files in the
read_data documentation.​

axel.

I guess that my problem is that i tried create bonds between groups and assign coefficients but the code checks for bond assignment (in bond.cpp) somewhere in between, which results in an error. I tried to comment that line but I was getting nan’s. Maybe is just something in my input where i do all the assignments, different from the one i sent before. I’ll keep trying to find the issue in my input file.

Thanks
Enrique

I guess that my problem is that i tried create bonds between groups and
assign coefficients but the code checks for bond assignment (in bond.cpp)
somewhere in between, which results in an error. I tried to comment that
line but I was getting nan's. Maybe is just something in my input where i
do all the assignments, different from the one i sent before. I'll keep
trying to find the issue in my input file.

​you are not paying attention.

you are creating just one type (don't confuse this with "style") of bond,
that means, there is just one set of parameters for *all* bonds.
with bond style harmonic, that means *all* bonds have the *same* parameters
(k and r0).

if you want those to be defined with an atom style variable, you *add* that
support to your bond style implementation.

also, as mentioned before, you *cannot* use $ expansion on atom style
variables. it doesn't make sense, since those don't resolve to a single
global value.
this is the last time, i'm repeating this. so please take note, and have a
closer look at the documentation than before. it is all there.

thanks for your understanding,
       axel.

This is the input I can’t make to work.

Thanks,
Enrique

in.bond (3.78 KB)

ATT00001.htm (17.5 KB)

This is the input I can’t make to work.

you specify bond_style multiple times. you must specify it only once
and move the command outside the loop.
every time LAMMPS encounters a bond_style command, all previous
bond_coeff settings are erased.

axel.