free_energy.py

Calculation functions

einstein_free_energy(temperature: float, volume: float, spring_constants: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], masses: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], natoms: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])

Computes the free energy for the Einstein solid at a given temperature.

Parameters:
  • temperature (float) – The temperature to use.

  • volume (float) – The volume of the system.

  • spring_constants (array-like object) – The Einstein solid spring constants for each atom type.

  • masses (array-like object) – The atomic masses for each atom type.

  • natoms (array-like object) – The number of atoms for each atom type.

Returns:

The total free energy evaluated for the Einstein solid.

Return type:

float

einstein_spring_constants(lammps_command: str, system: System, potential: Potential, temperature: float, mpi_command: str | None = None, equilsteps: int = 1000, springsteps: int = 50000, randomseed: int | None = None) dict

Runs an nvt simulation to evaluate atomic mean squared displacements in order to estimate a spring constant for an Einstein model.

Parameters:
  • lammps_command (str) – Command for running LAMMPS.

  • system (atomman.System) – The system to perform the calculation on.

  • potential (atomman.lammps.Potential) – The LAMMPS implemented potential to use.

  • mpi_command (str, optional) – The MPI command for running LAMMPS in parallel. If not given, LAMMPS will run serially.

  • temperature (float, optional) – The temperature to relax at (default is 0.0).

  • runsteps (int, optional) – The number of integration steps to perform (default is 50000).

  • randomseed (int or None, optional) – Random number seed used by LAMMPS in creating velocities and with the Langevin thermostat. (Default is None which will select a random int between 1 and 900000000.)

Returns:

Dictionary of results consisting of keys:

  • ’dumpfile_initial’ (str) - The name of the initial dump file created.

  • ’symbols_initial’ (list) - The symbols associated with the initial dump file.

  • ’dumpfile_final’ (str) - The name of the final dump file created.

  • ’symbols_final’ (list) - The symbols associated with the final dump file.

  • ’nsamples’ (int) - The number of thermodynamic samples included in the mean and standard deviation estimates. Can also be used to estimate standard error values assuming that the thermo step size is large enough (typically >= 100) to assume the samples to be independent.

  • ’E_pot’ (float) - The mean measured potential energy.

  • ’measured_pxx’ (float) - The measured x tensile pressure of the relaxed system.

  • ’measured_pyy’ (float) - The measured y tensile pressure of the relaxed system.

  • ’measured_pzz’ (float) - The measured z tensile pressure of the relaxed system.

  • ’measured_pxy’ (float) - The measured xy shear pressure of the relaxed system.

  • ’measured_pxz’ (float) - The measured xz shear pressure of the relaxed system.

  • ’measured_pyz’ (float) - The measured yz shear pressure of the relaxed system.

  • ’temp’ (float) - The mean measured temperature.

  • ’E_pot_std’ (float) - The standard deviation in the measured potential energy values.

  • ’measured_pxx_std’ (float) - The standard deviation in the measured x tensile pressure of the relaxed system.

  • ’measured_pyy_std’ (float) - The standard deviation in the measured y tensile pressure of the relaxed system.

  • ’measured_pzz_std’ (float) - The standard deviation in the measured z tensile pressure of the relaxed system.

  • ’measured_pxy_std’ (float) - The standard deviation in the measured xy shear pressure of the relaxed system.

  • ’measured_pxz_std’ (float) - The standard deviation in the measured xz shear pressure of the relaxed system.

  • ’measured_pyz_std’ (float) - The standard deviation in the measured yz shear pressure of the relaxed system.

  • ’temp_std’ (float) - The standard deviation in the measured temperature values.

Return type:

dict

free_energy(lammps_command: str, system: System, potential: Potential, temperature: float, mpi_command: str | None = None, spring_constants: float | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None, equilsteps: int = 25000, switchsteps: int = 50000, springsteps: int = 50000, pressure: float = 0.0, randomseed: int | None = None) dict

Performs a full dynamic relax on a given system at the given temperature to the specified pressure state.

Parameters:
  • lammps_command (str) – Command for running LAMMPS.

  • system (atomman.System) – The system to perform the calculation on.

  • potential (atomman.lammps.Potential) – The LAMMPS implemented potential to use.

  • temperature (float) – The temperature to run at.

  • mpi_command (str, optional) – The MPI command for running LAMMPS in parallel. If not given, LAMMPS will run serially.

  • spring_constants (float, array-like object or None, optional) – The Einstein solid spring constants to assign to each atom type. If None (default), then a separate simulation will estimate them using mean squared displacements.

  • equilsteps (int, optional) – The number of equilibration timesteps at the beginning of simulations to ignore before evaluations. This is used at the beginning of both the spring constant estimate and before each thermo switch run. Default value is 25000.

  • switchsteps (int, optional) – The number of integration steps to perform during each of the two switch runs. Default value is 50000.

  • springsteps (int, optional) – The number of integration steps to perform for the spring constants estimation, which is only done if spring_constants is None. Default value is 50000.

  • pressure (float, optional) – A value of pressure to use for computing the Gibbs free energy from the Helmholtz free energy. NOTE: this is not used to equilibrate the system during this calculation! Default value is 0.0.

  • randomseed (int or None, optional) – Random number seed used by LAMMPS. Default is None which will select a random int between 1 and 900000000.

Returns:

Dictionary of results consisting of keys:

  • ’spring_constants’ (list) - The Einstein spring constants assigned to each atom type.

  • ’work_forward’ (float) - The work/atom during the forward switching step.

  • ’work_reverse’ (float) - The work/atom during the reverse switching step.

  • ’work’ (float) - The reversible work/atom.

  • ’Helmholtz_reference’ (float) - The Helmholtz free energy/atom for the reference Einstein solid.

  • ’Helmholtz’ (float) - The Helmholtz free energy/atom.

  • ’Gibbs’ (float) - The Gibbs free energy/atom.

Return type:

dict

integrate_for_work(hamil_forward, hamil_reverse)