how to change the name of namespace LAMMPS_NS?

Hi all,
Can someone tell me how to change the name of the namespace in LAMMPS, which is by default “LAMMPS_NS”. Thank you.

Best regards,
Wenjing ZHOU

Hi all,
Can someone tell me how to change the name of the namespace in LAMMPS, which
is by default "LAMMPS_NS". Thank you.

well, just change it.

but why on earth do you want to do this??

axel.

Hi all,
Can someone tell me how to change the name of the namespace in LAMMPS, which
is by default "LAMMPS_NS". Thank you.

well, just change it.

in order to preempt the next question, i should suggest the use of the
stream editor "sed" as the simplest option. the GNU version of sed has
an "inplace" option that makes it a breeze: sed -i -e
's/LAMMPS_NS/WTF/g' *.cpp *.h

Thanks, axel. The reason why I want to change the name of namespace is that I want to do two simulations using LAMMPS in parallel, and make them coupled. So I need to call two libraries made by two different LAMMPSs in my own code. I tried to change all LAMMPS_NS to LAMMPS_NEW, but I was told that the new namespace LAMMPS_NEW didn’t exist.

Thanks, axel. The reason why I want to change the name of namespace is that
I want to do two simulations using LAMMPS in parallel, and make them
coupled. So I need to call two libraries made by two different LAMMPSs in my

no, you don't. not at all.

all you need is to create two *instances* of the Lammps class
and if you want to run in parallel, you also first need to split the
world communicator into two parts and use the resulting sub
communicators to initialize the lammps classes. check out the lammps
library interface. also the replica/partition interface uses lammps in
a similar way. this is basic c++ stuff.

own code. I tried to change all LAMMPS_NS to LAMMPS_NEW, but I was told that
the new namespace LAMMPS_NEW didn't exist.

told by whom?

axel.

I am sorry for not explaining the problem clearly enough, what I want to do is actually not a parallel coupling problem, but a sequential coupling problem. For example, after 1000 timesteps for the first program, all of the world communicators will be used by the second program, meanwhile the first one will be paused. So when I creat two programs using the same namespace in LAMMPS, will it work like this?

Wenjing ZHOU

I am sorry for not explaining the problem clearly enough, what I want to do
is actually not a parallel coupling problem, but a sequential coupling

same difference.

problem. For example, after 1000 timesteps for the first program, all of the
world communicators will be used by the second program, meanwhile the first
one will be paused. So when I creat two programs using the same namespace in
LAMMPS, will it work like this?

this has *nothing* to do with namespaces. please update your C++
knowledge. this is independent of *how* something is named, it only
depends on having different class *instances*. you don't don't need a
different integer type because you have created already an int
variable named "i", do you?. lets just use a stupid example. for
example you can do something like this:

#include "mpi.h"
#include "lammps.h"
#include "input.h"
#include "string.h"

using namespace LAMMPS_NS;

/* ----------------------------------------------------------------------
   main program to drive LAMMPS
------------------------------------------------------------------------- */
char *args1[] = {
    (char *) "lammps1",
    (char *) "-log",
    (char*) "log.lammps-1",
     0};

char *args2[] = {
    (char *) "lammps2",
    (char *) "-log",
    (char*) "log.lammps-2",
     0};

int main(int argc, char **argv)
{
  MPI_Init(&argc,&argv);

  LAMMPS *lammps1, *lammps2;

  lammps1 = new LAMMPS(3,args1,MPI_COMM_WORLD);
  lammps2 = new LAMMPS(3,args2,MPI_COMM_WORLD);

  lammps1->input->file("in.init-1");
  lammps2->input->file("in.init-2");

  for (int i=0; i < 10; i++) {
    lammps1->input->one("run 1000");
    lammps2->input->one("run 1000");
  }

  delete lammps1;
  delete lammps2;

  MPI_Finalize();
}

this will create two instances of lammps, feed each a different input
script and then alternately propagate the system with 1000 steps and
do so in parallel. then delete the class instances (and their contexts
and system information) and then finish. easy as pie. no crazy rename
needed.

axel.

Thank you for answering my questions patiently, axel. I appreciate it so much.
In fact I have done my coupling exactly in the same way as the example you have given. I used different pair potentials for each input file, one is LJ, the other is DSMC. But the error always came up as"Exit code -5 signaled from b522, Killing remote processes…MPI process terminated unexpectedly" when the second loop began for DSMC. Maybe there are some mpi problems in pair_dsmc.cpp. I should check this file carefully.

Best regards,
Wenjing ZHOU

Thank you for answering my questions patiently, axel. I appreciate it so
much.
In fact I have done my coupling exactly in the same way as the example you

... and again we have an example that demonstrates how important it is
to provide a detailed description of what a problem is all about and
what had been attempted so far. we could have saved a massive amount
of time, if you had not just asked a pointless question but rather
properly explained your predicament.

have given. I used different pair potentials for each input file, one is LJ,
the other is DSMC. But the error always came up as"Exit code -5 signaled
from b522, Killing remote processes...MPI process terminated unexpectedly"
when the second loop began for DSMC. Maybe there are some mpi problems in
pair_dsmc.cpp. I should check this file carefully.

why should that be? can you run the same input without your weird
side-by-side simulation? and are you doing any other manipulations
between the two side-by-side sims?

axel.

The LAMMPS lib interface allows multiple versions of LAMMPS
to be instantiated, as Axel said. You do that with a MPI communicator
that you pass it. You can instantiate it twice with the same MPI
communicator. Your calling program will only use one instance
at a time, whether they use the same communicator or not.

Steve