Segmentation fault with template molecule atom_style + shake fix

Hi

I am trying to do a test simulation with the template molecule atom_style and shake fix.
For this test simulation, I have defined the water molecule as a template and randomly
insert a single molecule in the simulation box using create_atoms. When I do

“run” I get a segmentation fault when shake fix is on, but, when shake fix is off, there is

no segfault.

I will try to find the cause using gdb. In the mean time, I would appreciate

is somebody can have a look at my input files (attached), suggest how to resolve this.

Thanks
Sikandar

h2o.txt (436 Bytes)

in.bulkwater (1.09 KB)

Hi

I am trying to do a test simulation with the template molecule atom_style
and shake fix.
For this test simulation, I have defined the water molecule as a template
and randomly
insert a single molecule in the simulation box using create_atoms. When I do
"run" I get a segmentation fault when shake fix is on, but, when shake fix
is off, there is
no segfault.

I will try to find the cause using gdb. In the mean time, I would appreciate
is somebody can have a look at my input files (attached), suggest how to
resolve this.

this needs programming.

fix shake triggers building a partial bond list, which is currently
incompatible with atom_style template.

axel

Hi

I am trying to do a test simulation with the template molecule atom_style
and shake fix.
For this test simulation, I have defined the water molecule as a template
and randomly
insert a single molecule in the simulation box using create_atoms. When I do
"run" I get a segmentation fault when shake fix is on, but, when shake fix
is off, there is
no segfault.

I will try to find the cause using gdb. In the mean time, I would appreciate
is somebody can have a look at my input files (attached), suggest how to
resolve this.

this needs programming.

this is a *very* wild guess for a fix, but it might just work. please
give it a try and let us know. thanks.

[[email protected]... src]$ git diff
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 70807f4..30ff8b3 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -859,20 +859,20 @@ void Neighbor::init()

   // set ptrs to topology build functions

- if (bond_off) bond_build = &Neighbor::bond_partial;
- else if (atom->molecular == 2) bond_build = &Neighbor::bond_template;
+ if (atom->molecular == 2) bond_build = &Neighbor::bond_template;
+ else if (bond_off) bond_build = &Neighbor::bond_partial;
   else bond_build = &Neighbor::bond_all;

- if (angle_off) angle_build = &Neighbor::angle_partial;
- else if (atom->molecular == 2) angle_build = &Neighbor::angle_template;
+ if (atom->molecular == 2) angle_build = &Neighbor::angle_template;
+ else if (angle_off) angle_build = &Neighbor::angle_partial;
   else angle_build = &Neighbor::angle_all;

- if (dihedral_off) dihedral_build = &Neighbor::dihedral_partial;
- else if (atom->molecular == 2) dihedral_build = &Neighbor::dihedral_template;
+ if (atom->molecular == 2) dihedral_build = &Neighbor::dihedral_template;
+ else if (dihedral_off) dihedral_build = &Neighbor::dihedral_partial;
   else dihedral_build = &Neighbor::dihedral_all;

- if (improper_off) improper_build = &Neighbor::improper_partial;
- else if (atom->molecular == 2) improper_build = &Neighbor::improper_template;
+ if (atom->molecular == 2) improper_build = &Neighbor::improper_template;
+ else if (improper_off) improper_build = &Neighbor::improper_partial;
   else improper_build = &Neighbor::improper_all;

   // set topology neighbor list counts to 0

Hi Axel,

The patch you provided seems to have resolved the issue of segmentation fault in fix shake with
template molecule atom_style. I will let you know if I face any further issues.

Thanks,
Sikandar

All of Axel’s bug-fixes for atom-style template will
be in the latest patch (4May).

Sikandar - my Q for you is whether these fix all
the problem you’ve seen. In particular the one
you mentioned with write_data not getting the

per-atom molecule info correct …

thanks,
Steve

Hi Steve

There were 3 issues I faced when using atom-style template.

The first was write_data was writing garbage values for nbonds and nangles. It was fixed by the Axel’s patch:

http://git.lammps.org/git/?p=lammps-icms.git;a=commitdiff;h=09fcfe4c2f1e06f19528664406bc36f0f674c2c5

The second issue was with fix shake. When fix shake was applied with atom_style template, I was getting a
segfault. It was resolved with the Axel’s patch attached at the end of the email.

The third issue I faced is using atom_style hybrid charge template. When the atom_style is set to hybrid with charge template H2O, write_data fails to write template-index and template-atom accurately in Atoms section. I
n fact, it writes the values for template-index and template-atom same as molecule-ID. I guess this issue
still exists. As Axel pointed out, the manual warns against using the hybrid style with the template. I have attached the files to reproduce this issue.

I have not yet faced any other issues. I will post if I have any updates.

Thanks,
Sikandar

The patch which resolved segfault:

diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 70807f4…30ff8b3 100644
— a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -859,20 +859,20 @@ void Neighbor::init()

// set ptrs to topology build functions

  • if (bond_off) bond_build = &Neighbor::bond_partial;
  • else if (atom->molecular == 2) bond_build = &Neighbor::bond_template;
  • if (atom->molecular == 2) bond_build = &Neighbor::bond_template;
  • else if (bond_off) bond_build = &Neighbor::bond_partial;
    else bond_build = &Neighbor::bond_all;
  • if (angle_off) angle_build = &Neighbor::angle_partial;
  • else if (atom->molecular == 2) angle_build = &Neighbor::angle_template;
  • if (atom->molecular == 2) angle_build = &Neighbor::angle_template;
  • else if (angle_off) angle_build = &Neighbor::angle_partial;
    else angle_build = &Neighbor::angle_all;
  • if (dihedral_off) dihedral_build = &Neighbor::dihedral_partial;
  • else if (atom->molecular == 2) dihedral_build = &Neighbor::dihedral_template;
  • if (atom->molecular == 2) dihedral_build = &Neighbor::dihedral_template;
  • else if (dihedral_off) dihedral_build = &Neighbor::dihedral_partial;
    else dihedral_build = &Neighbor::dihedral_all;
  • if (improper_off) improper_build = &Neighbor::improper_partial;
  • else if (atom->molecular == 2) improper_build = &Neighbor::improper_template;
  • if (atom->molecular == 2) improper_build = &Neighbor::improper_template;
  • else if (improper_off) improper_build = &Neighbor::improper_partial;
    else improper_build = &Neighbor::improper_all;

// set topology neighbor list counts to 0

h2o.txt (436 Bytes)

in.create_atoms (502 Bytes)

thanks for the good test files

this was a simple fix - in src/MOLECULE/atom_vec_template.cpp
you need to edit this line - the indices on buf were wrong for
the last 2:

int AtomVecTemplate::write_data_hybrid(FILE *fp, double *buf)
{
fprintf(fp," " TAGINT_FORMAT " %d %d",
(tagint) ubuf(buf[0]).i,(int) ubuf(buf[1]).i,(int) ubuf(buf[2]).i);

will be in the next patch

Note that it should be fine to use atom_style hybrid with template,
so long as none of the other styles store bond, angle, etc info.

Also, if all you want to do is add charge, you could use
fix property/atom and not use a hybrid atom style.

Steve