LAMMPS vector sizes

Hi there,

Q1)
I am trying to couple LAMMPS to a Finite Element code to implement the
Arlequin method. My Finite Element code is in Fortran and I need to
access the LAMMPS variables from Fortran. So I've written an interface
something similar to the "library.cpp" to extract variables (something
like lammps_extract_global). I create Fortran pointers and I map the
Fortran pointers to the C++ pointers knowing the size and the starting
address.

The question is now, how do I know that some variable in LAMMPS is
allocated already and what is the size? The problem us if try to map a
variable which is not allocated in LAMMPS my program crashes. Is there
any document and says what is the size of every array?

Q2)
For my coupling method, I need to scale the atomic forces with some
weighting for those atoms that fall in the coupling region. How I can
do this without touching every single potential that I want to use?

Cheers
Hossein

See comments below.

Steve

Hi there,

Q1)
I am trying to couple LAMMPS to a Finite Element code to implement the
Arlequin method. My Finite Element code is in Fortran and I need to
access the LAMMPS variables from Fortran. So I've written an interface
something similar to the "library.cpp" to extract variables (something
like lammps_extract_global). I create Fortran pointers and I map the
Fortran pointers to the C++ pointers knowing the size and the starting
address.

The question is now, how do I know that some variable in LAMMPS is
allocated already and what is the size? The problem us if try to map a
variable which is not allocated in LAMMPS my program crashes. Is there
any document and says what is the size of every array?

See variable.h. There is a find() method, so if you
do something like:

input->variable->find(name) you will check
if the variable with name exists.

Q2)
For my coupling method, I need to scale the atomic forces with some
weighting for those atoms that fall in the coupling region. How I can
do this without touching every single potential that I want to use?

Not sure what you are asking. Thru the LAMMPS lib interface
you can set or scale forces however you wish. If you have
already called (any) potential, then you could adjust the forces
afterwards.

Dear Steve,

The question is now, how do I know that some variable in LAMMPS is allocated already and what is the size? The problem us if try to map a variable which is not allocated in LAMMPS my program crashes. Is there any document and says what is the size of every array?

See variable.h. There is a find() method, so if you do something like:
input->variable->find(name) you will check if the variable with name exists.

Probably I did not explain it properly. I mean, how do I know for
example a variable like "atom->x0" is allocated and what is the size?
The " input->variable->find(name) " is used for the user defined
variables, right?

Q2)
For my coupling method, I need to scale the atomic forces with some weighting for those atoms that fall in the coupling region. How I can do this without touching every single potential that I want to use?

Not sure what you are asking. Thru the LAMMPS lib interface you can set or scale forces however you wish. If you have already called (any) potential, then you could adjust the forces afterwards.

I can modify the forces, but it is not possible for modify the forces
afterwards. The scenario is like this:

I have a Continuum region (with Finite Elements) and I put an
atomistic region on top. Then I define a Handshake region; this
handshake region has a thickness. The parameter \\alpha is the
weighting and changes from 0 to 1 inside the Handshake region.
Therefore the Force and Mass of every atom that falls inside the
atomistic region should be Multiplied by \\alpha during the Force
computation. in other words the force between two atoms is:

    Fij= 0.5 * (\alpha_i+ \alpha_j) * fij

This can not be done after force computation since we cannot factor
out \\alpha.

I can of course modify the LAMMPS source and add the weighting values
to the potentials that I'm interested. But this is not standard.

What do you think?

Cheers
Hossein

Comments below.

Steve

Dear Steve,

The question is now, how do I know that some variable in LAMMPS is allocated already and what is the size? The problem us if try to map a variable which is not allocated in LAMMPS my program crashes. Is there any document and says what is the size of every array?

See variable.h. There is a find() method, so if you do something like:
input->variable->find(name) you will check if the variable with name exists.

Probably I did not explain it properly. I mean, how do I know for
example a variable like "atom->x0" is allocated and what is the size?
The " input->variable->find(name) " is used for the user defined
variables, right?

The variable atom->nmax is the allocated size
of all per-atom arrays, such as atom->x.

Q2)
For my coupling method, I need to scale the atomic forces with some weighting for those atoms that fall in the coupling region. How I can do this without touching every single potential that I want to use?

Not sure what you are asking. Thru the LAMMPS lib interface you can set or scale forces however you wish. If you have already called (any) potential, then you could adjust the forces afterwards.

I can modify the forces, but it is not possible for modify the forces
afterwards. The scenario is like this:

I have a Continuum region (with Finite Elements) and I put an
atomistic region on top. Then I define a Handshake region; this
handshake region has a thickness. The parameter \\alpha is the
weighting and changes from 0 to 1 inside the Handshake region.
Therefore the Force and Mass of every atom that falls inside the
atomistic region should be Multiplied by \\alpha during the Force
computation. in other words the force between two atoms is:

Fij= 0.5 * (\alpha_i+ \alpha_j) * fij

This can not be done after force computation since we cannot factor
out \\alpha.

I can of course modify the LAMMPS source and add the weighting values
to the potentials that I'm interested. But this is not standard.

The fix AtC package does something conceptually similar in that
it couples atoms in a handshake region to continuum.

If you write a fix, it can be invoked at different places within
the timestep, e.g. immediately after pairwise forces have been
computed, to add an additional force. The fix can
make calls to an external lib, which is what fix AtC does,
or you could use somethink like fix external, which can make
a call-back thru the library interface to the driving code that
is calling LAMMPS, which sounds possiibly like what you are
doing.