accessing thermo bond keywords

Hi,

I have been trying to set a variable to the thermo keyword bonds but I always get a value of 0. The code I use is:

variable nbonds equal bonds
thermo_style custom bonds v_nbonds

The result is that the thermo output prints a value for bonds but always a 0 for v_nbonds.

Upon inspection of the thermo.cpp file I believe I have found the cause of the issue:

Thermo::parse_fields sets up bonds,angles,dihedrals,impropers as BIGINT’s but Thermo::evaluate_keyword has the call to Thermo::compute_ for each of these return a bivalue that is never passed to dvalue. All other BIGINT thermo keywords (atoms,step,etc) are passed to dvalue in Thermo::evaluate_keyword.

I hacked at line 1372 of thermo.cpp with:

else if (strcmp(word,“bonds”) == 0) {
compute_bonds();
dvalue = bivalue;
}

and my variable nbonds contains the bonds value as expected. I wanted to check that this was not messing anything up down the line. My code is from the May 4 2017 release and the behavior is the same in lammps-daily for ubuntu.

Thanks!

Kurt

Hi,

I have been trying to set a variable to the thermo keyword bonds but I
always get a value of 0. The code I use is:

variable nbonds equal bonds
thermo_style custom bonds v_nbonds

The result is that the thermo output prints a value for bonds but always a
0 for v_nbonds.

Upon inspection of the thermo.cpp file I believe I have found the cause of
the issue:

Thermo::parse_fields sets up bonds,angles,dihedrals,impropers as BIGINT's
but Thermo::evaluate_keyword has the call to Thermo::compute_ for each of
these return a bivalue that is never passed to dvalue. All other BIGINT
thermo keywords (atoms,step,etc) are passed to dvalue in
Thermo::evaluate_keyword.

I hacked at line 1372 of thermo.cpp with:

else if (strcmp(word,"bonds") == 0) {
    compute_bonds();
    dvalue = bivalue;

}

​this is a workaround and not the correct fix. the problem has to lie
elsewhere.
we will take a look.

axel.​

correction, i misread your e-mail and overlooked the fact, that it was the variable computation that failed and not the thermo keyword as such.
since variables store numbers internally as doubles, your suggestion is correct and should be expanded to angles/dihedrals/impropers as well.

axel.