Units_Style

Dear Users and Developers,
Hi,

I have a question about “Units (lj, real, …)” in the source codes of the LAMMPS.

I’ve written a specific code and I want to have a command for choosing type of “Units” according to the values of parameters in my own code.

How can I declare Units_type in the Scripts codes?

For Example, a user uses the “lj units” at his/her code, so I should consider specific and different values according to dimensionless or other Units styles, how can I determine the Units_Style in my own Script?

I think it should be a command like below:

{

.

.

.

char *Unitsstyle == units_style();

if ( Unitsstyle == ‘lj’)

UNIT_flag=1;

else UNIT_flag=0;

.

.

.

}

Dear Users and Developers,
Hi,

I have a question about "Units (lj, real, …)" in the source codes of the
LAMMPS.

I've written a specific code and I want to have a command for choosing type
of "Units" according to the values of parameters in my own code.

How can I declare Units_type in the Scripts codes?

what you are asking are two questions:

how do i parse a keyword?

and

how do i implement support for different unit settings?

[...]

I think it should be a command like below:

{

char *Unitsstyle == units_style();

if ( Unitsstyle == 'lj')

UNIT_flag=1;

else UNIT_flag=0;
}

no. this is rubbish. where did you learn your C/C++ programming?

things like that you can *easily* find out through
_reading_ the lammps source code. with just a
tiny effort (and creative use of commands like 'grep')
you'll find that the units keywords is recognized
in input.cpp and then acted upon in update.cpp
(more exactly in the Update::set_units() method).

this will not only show you how to properly compare strings,
it will also show you that lammps handles different unit
systems by assigning different values to some fundamental
scaling factors that are used throughout the code.
they are all part of the Force class and documented in
the force.h header file.

there you go. any questions?

axel.