Note
Go to the end to download the full example code.
Unit ConversionΒΆ
Convert LAMMPS units to SI or other unit systems:
Supported unit styles:
real
- kcal/mol, Angstrom, fsmetal
- eV, Angstrom, pssi
- kg, m, snano
- attogram, nanometer, nanosecondlj
- Lennard-Jones reduced units (requires polymer specification)
/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pylimer_tools/io/unit_styles.py:179: UserWarning: LJ unit styles are derived. Reference used: https://doi.org/10.1021/acs.macromol.9b02428
warnings.warn(
LJ 1 Pressure in Pascal: 101325.0
from pylimer_tools.io.unit_styles import UnitStyleFactory
# Create unit style factory
unit_factory = UnitStyleFactory()
# Get unit conversion for specific LAMMPS unit style
real_units = unit_factory.get_unit_style("real")
metal_units = unit_factory.get_unit_style("metal")
# For LJ units, specify the polymer
lj_units = unit_factory.get_unit_style("lj", polymer="pdms")
# Convert pressure from LAMMPS units to SI
pressure_si = (1 * real_units.pressure).to("Pa").magnitude # type: ignore
# Convert temperature (already in Kelvin for 'real' units)
temperature_si = (
273.15 *
real_units.temperature).to("K").magnitude # type: ignore
print(f"LJ 1 Pressure in Pascal: {pressure_si}")
Total running time of the script: (0 minutes 0.188 seconds)