# System properties This section documents the following functions: - `lammps_get_natoms`{.interpreted-text role="cpp:func"} - `lammps_get_thermo`{.interpreted-text role="cpp:func"} - `lammps_last_thermo`{.interpreted-text role="cpp:func"} - `lammps_extract_box`{.interpreted-text role="cpp:func"} - `lammps_reset_box`{.interpreted-text role="cpp:func"} - `lammps_memory_usage`{.interpreted-text role="cpp:func"} - `lammps_get_mpi_comm`{.interpreted-text role="cpp:func"} - `lammps_extract_setting`{.interpreted-text role="cpp:func"} - `lammps_extract_global_datatype`{.interpreted-text role="cpp:func"} - `lammps_extract_global`{.interpreted-text role="cpp:func"} ------------------------------------------------------------------------ The library interface allows the extraction of different kinds of information about the active simulation instance and also - in some cases - to apply modifications to it. This enables combining of a LAMMPS simulation with other processing and simulation methods computed by the calling code, or by another code that is coupled to LAMMPS via the library interface. In some cases the data returned is direct reference to the original data inside LAMMPS, cast to a void pointer. In that case the data needs to be cast to a suitable pointer for the calling program to access it, and you may need to know the correct dimensions and lengths. This also means you can directly change those value(s) from the calling program (e.g., to modify atom positions). Of course, changing values should be done with care. When accessing per-atom data, please note that these data are the per-processor **local** data and are indexed accordingly. Per-atom data can change sizes and ordering at every neighbor list rebuild or atom sort event as atoms migrate between subdomains and processors. ``` c #include "library.h" #include int main(int argc, char **argv) { void *handle; int i; handle = lammps_open_no_mpi(0, NULL, NULL); lammps_file(handle,"in.sysinit"); printf("Running a simulation with %g atoms.\n", lammps_get_natoms(handle)); printf(" %d local and %d ghost atoms. %d atom types\n", lammps_extract_setting(handle,"nlocal"), lammps_extract_setting(handle,"nghost"), lammps_extract_setting(handle,"ntypes")); double *dt = (double *)lammps_extract_global(handle,"dt"); printf("Changing timestep from %g to 0.5\n", *dt); *dt = 0.5; lammps_command(handle,"run 1000 post no"); for (i=0; i < 10; ++i) { lammps_command(handle,"run 100 pre no post no"); printf("PE = %g\nKE = %g\n", lammps_get_thermo(handle,"pe"), lammps_get_thermo(handle,"ke")); } lammps_close(handle); return 0; } ``` ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_get_natoms ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_get_thermo ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_last_thermo ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_extract_box ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_reset_box ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_memory_usage ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_get_mpi_comm ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_extract_setting ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_extract_global_datatype ::: ------------------------------------------------------------------------ ::: {.doxygenfunction project="progguide"} lammps_extract_global :::