SimulationTemperatureProfile

Included in QATK.Dynamics

class SimulationTemperatureProfile(initial_value, initial_gradient=None, update_frequency=None, total_steps=None)

Class for creating a profile of temperature values for use during a dynamics simulation.

Parameters:
  • initial_value (PhysicalQuantity of type temperature) – The initial value of the temperature at step 0.

  • initial_gradient (PhysicalQuantity of type temperature | None) – The initial gradient of the temperature. if None is given the gradient is assumed to be zero. The gradient is in terms of change of the temperature over the fraction of the simulation.

  • update_frequency (int | None) – The step frequency with which the temperature is updated during the simulation.

  • total_steps (int | None) – The total number of steps in the simulation. This allows the conversion from fraction of simulation to step number. If None is given it must be set later before use.

addQuantityValue(fraction, value, gradient=None)

Add a new value of the quantity at the given fraction of the simulation.

Parameters:
  • fraction (float) – The fraction of the simulation at which the quantity value is defined. Must be between 0 and 1.

  • value (PhysicalQuantity) – The value of the quantity at the given fraction.

  • gradient (PhysicalQuantity | None) – The gradient of the quantity at the given fraction. If None is given the gradient is assumed to be zero. The gradient is in terms of change of the quantity over the fraction of the simulation.

setTotalSteps(total_steps)

Set the total number of steps in the simulation.

Parameters:

total_steps (int) – The total number of steps in the simulation.

setUpdateFrequency(frequency)

Set the frequency, in number of steps, the quantity from the profile is used to update the simulation.

Parameters:

frequency (int) – The number of steps between quantity updates.

setValueFunction(function)

Set a custom function for calculating the value of the quantity at a given step in the simulation. The function takes in the fraction of the simulation performed, which ranges from 0 to 1, and returns the value corresponding to that fraction.

An example use of this might be to set a function might be to sinusoidally vary a parameter during the simulations.

Parameters:

function (function | None) – A function that takes in a float between 0 and 1, and returns a PhysicalQuantity. None restores the default linear interpolation function.

totalSteps()
Returns:

The total number of steps in the simulation, if set.

Return type:

int | None

uniqueString()

Return a unique string representing the state of the object.

updateFrequency()
Returns:

The step frequency with which the quantity is updated during the simulation.

Return type:

int

value(step)

Get the value of the quantity at the given step in the simulation.

Parameters:

step (int) – The step in the simulation for which the quantity value is requested.

Returns:

The value of the quantity at the given step.

Return type:

PhysicalQuantity

Usage Examples

Perform a melt-quench simulation on amorphous polydimethylsiloxane. The configuration is heated from 300K to 600K over 30 ps, then simulated at 600K for 40 ps, and then returned to 300K over the next 30 ps.

# Set the temperature profile
temperature_profile = SimulationTemperatureProfile(
    initial_value=300*Kelvin,
    initial_gradient=1000*Kelvin
)
temperature_profile.addQuantityValue(0.3, 600*Kelvin, gradient=0*Kelvin)
temperature_profile.addQuantityValue(0.7, 600*Kelvin, gradient=-1000*Kelvin)

# Run the simulation
simulation.simulate(100000, profiles=[temperature_profile])

equilibrated_pdms.hdf5 temperature_profile_example.py

Notes

The SimulationTemperatureProfile adds a temperature profile to a soft matter dynamics simulation. The profile is implemented so that the temperature can be constantly updated during the simulation. Profiles work by taking both the value, and optionally the gradient of the temperature at different points. These can then be used to construct a piecewise linear function of the temperature during the simulation. This can be used to implement a number of simulation protocols, such as simulated annealing or equilibration protocols.

When specifying temperatures and gradients, everything is specified with reference to the fraction of the simulation completed. In this the profile is both independent of the number of steps in the simulation and also the time step. Gradients are likewise given as the instantaneous rate of change over the whole simulation.

Profiles are created by giving an initial temperature and optionally temperature gradient. Gradients are optional, and when not specified are assumed to be zero. Additional points on the profile are added with the addQuantityValue method. This takes the fraction of the simulation progress, the temperature at that point and optionally a gradient of the temperature from that point. If the value from the last segment does not match the new temperature the temperature profile is discontinuous.

It is also possible to define a profile using a user-defined function. In this way profiles such as sinusoidal or other shapes can be easily implemented. The function is given with the setValueFunction method. This function should take as an argument the fraction of the simulation and return a temperature. Custom functions are not saved as part of the profile when it is written with nlsave, and thus must be re-set if a profile is used from a file.