|
MolSim
|
Class modeling a thermostat which regulates the temperature of a Particle system. More...
#include <Thermostat.h>
Public Member Functions | |
| Thermostat (ParticleContainer &particles) | |
| Construct a new Thermostat with default-initialized values. | |
| Thermostat (ParticleContainer &particles, int dimension, double T_init, int n_thermostat, double T_target, double delta_T, bool initBrownianMotion, bool nanoFlow=false) | |
| Construct a complete Thermostat object with all parameters. | |
| ~Thermostat () | |
| Destroys the current Thermostat object. | |
| void | initialize (int dimension, double T_init, int n_thermostat, double T_target, double delta_T, bool initBrownianMotion, bool nanoFlow=false, bool limitScaling=false) |
| Initialize the current Thermostat's parameters. | |
| void | initializeBrownianMotion () |
| Initialize the Particle velocities with Brownian Motion. | |
| void | calculateKineticEnergy () |
| Calculates the kinetic energy \( E_{kin} \) for all Particle objects in the system. | |
| void | calculateTemp () |
| Calculates the current temperature \( T \) of the system. | |
| void | calculateScalingFactor () |
| Calculates the scaling factor \( \beta \). | |
| void | calculateThermalMotions () |
| Calculates the thermal motion of each Particle in the system. | |
| void | updateSystemTemp (int currentStep) |
| Updates the system temperature after the number of iterations specified inside the Thermostat object. | |
| double | getKineticEnergy () const |
| Gets the kinetic energy \( E_{kin} \) of the active simulation particles. | |
| double | getTemp () const |
| Gets the current temperature \( T \) of the system. | |
| double | getInitTemp () const |
| Gets the starting temperature \( T_{init} \) of the system. | |
| double | getTargetTemp () const |
| Gets the target temperature \( T_{target} \) of the system. | |
| double | getDeltaT () const |
| Gets the maximum temperature difference \( \Delta T \) in one Thermostat application. | |
| double | getScalingFactor () const |
| Gets the scaling factor \( \beta \) by which to scale the Particle velocities. | |
| bool | doScalingLimit () const |
| Checks if the Thermostat should apply gradual or direct velocity scaling. | |
| int | getTimestep () const |
| Gets the number of simulation iterations after which to apply the Thermostat functionality. | |
| bool | getNanoflow () const |
| Determines whether the thermostat is used for the nano-scale flow simulation. | |
| ParticleContainer & | getParticles () const |
| Gets a reference to the Particle system. | |
| bool | operator== (const Thermostat &other) const |
| Overload of the equality operator. Checks if two Thermostat objects have the same values. | |
Private Attributes | |
| int | dimension {2} |
| The dimensions for which the Thermostat temperature regulation should be applied (default: 2). | |
| double | kineticEnergy {0.0} |
| The kinetic energy \( E_{kin} \) of the active simulation particles (default: 0). | |
| double | temperature {0.0} |
| The Temperature \( T \) of the system (default: 0). | |
| double | scalingFactor {1.0} |
| The scaling factor \( \beta \) by which to scale the Particle velocities (default: 1). | |
| double | T_init {0.0} |
| The starting temperature \( T_{init} \) of the system (default: 0). | |
| double | T_target {0.0} |
| The target temperature \( T_{target} \) of the system (default: \( T_{init} \)). | |
| int | n_thermostat {1000} |
| The number of simulation iterations after which to apply the Thermostat functionality (default: 1000). | |
| double | delta_T {INFINITY} |
| The maximum temperature difference \( \Delta T \) in one Thermostat application (default: \( \infty
\)). | |
| bool | limitScaling {false} |
| Determines if the Thermostat should apply gradual velocity scaling or direct velocity scaling (default: direct). | |
| bool | initBrownianMotion {true} |
| Determines whether or not to initialize the velocities with Brownian Motion (default: on). | |
| bool | nanoFlow {false} |
| Determines whether the thermostat is used for the nano-scale flow simulation. | |
| std::array< double, 3 > | avg_velocity {0, 0, 0} |
| Average velocity of the system. | |
| ParticleContainer & | particles |
| A reference to the Particle system. | |
Class modeling a thermostat which regulates the temperature of a Particle system.
|
explicit |
Construct a new Thermostat with default-initialized values.
| particles | The ParticleContainer representing the Particle system. |
| Thermostat::Thermostat | ( | ParticleContainer & | particles, |
| int | dimension, | ||
| double | T_init, | ||
| int | n_thermostat, | ||
| double | T_target, | ||
| double | delta_T, | ||
| bool | initBrownianMotion, | ||
| bool | nanoFlow = false |
||
| ) |
Construct a complete Thermostat object with all parameters.
| particles | The ParticleContainer representing the Particle system. |
| dimension | The dimensions for which the Thermostat temperature regulation should be applied. |
| T_init | The starting temperature \( T_{init} \) of the system. |
| n_thermostat | The number of simulation iterations after which to apply the Thermostat functionality. |
| T_target | The target temperature \( T_{target} \) of the system. |
| delta_T | The maximum temperature difference \( \Delta T \) in one Thermostat application. |
| initBrownianMotion | Determines whether or not to initialize the velocities with Brownian Motion. |
| nanoFlow | Determines whether the thermostat is used for the nano-scale flow simulation. |
| Thermostat::~Thermostat | ( | ) |
Destroys the current Thermostat object.
| void Thermostat::calculateKineticEnergy | ( | ) |
| void Thermostat::calculateScalingFactor | ( | ) |
Calculates the scaling factor \( \beta \).
The scaling factor is calculated using the formula
\[ \beta = \sqrt{\frac{T_{new}}{T_{current}}} \]
where \( T_{new} \) is either the target temperature if no limit \( \Delta T \) is given or if the target temperature can be reached in the next thermostat application, or \( T_{current} \pm \Delta T \) otherwise (depending if the current temperature is above or below the target temperature).
| void Thermostat::calculateTemp | ( | ) |
Calculates the current temperature \( T \) of the system.
The temperature is calculated after getting the kinetic energy \( E_{kin} \) of all Particle objects in the system by rearranging the equation
\[ E_{kin} = \frac{D \cdot N}{2}k_B T \]
and solving for \( T \), with \( N \) being the total number of active Particle objects, \( D \) being the number of dimensions and \( k_B = 1 \).
| void Thermostat::calculateThermalMotions | ( | ) |
Calculates the thermal motion of each Particle in the system.
First, the average velocity
\[ \tilde v = \frac1N \sum_{i=0}^N v_i \]
is determined using the velocities of each non-wall particle in the system. Then, for each particle, its thermal motion \( \hat v_i \) is calculated as the difference between the velocity and the average velocity.
| bool Thermostat::doScalingLimit | ( | ) | const |
Checks if the Thermostat should apply gradual or direct velocity scaling.
| double Thermostat::getDeltaT | ( | ) | const |
Gets the maximum temperature difference \( \Delta T \) in one Thermostat application.
| double Thermostat::getInitTemp | ( | ) | const |
Gets the starting temperature \( T_{init} \) of the system.
| double Thermostat::getKineticEnergy | ( | ) | const |
Gets the kinetic energy \( E_{kin} \) of the active simulation particles.
| bool Thermostat::getNanoflow | ( | ) | const |
Determines whether the thermostat is used for the nano-scale flow simulation.
| ParticleContainer & Thermostat::getParticles | ( | ) | const |
Gets a reference to the Particle system.
| double Thermostat::getScalingFactor | ( | ) | const |
Gets the scaling factor \( \beta \) by which to scale the Particle velocities.
| double Thermostat::getTargetTemp | ( | ) | const |
Gets the target temperature \( T_{target} \) of the system.
| double Thermostat::getTemp | ( | ) | const |
Gets the current temperature \( T \) of the system.
| int Thermostat::getTimestep | ( | ) | const |
Gets the number of simulation iterations after which to apply the Thermostat functionality.
| void Thermostat::initialize | ( | int | dimension, |
| double | T_init, | ||
| int | n_thermostat, | ||
| double | T_target, | ||
| double | delta_T, | ||
| bool | initBrownianMotion, | ||
| bool | nanoFlow = false, |
||
| bool | limitScaling = false |
||
| ) |
Initialize the current Thermostat's parameters.
| dimension | The dimensions for which the Thermostat temperature regulation should be applied. |
| T_init | The starting temperature \( T_{init} \) of the system. |
| n_thermostat | The number of simulation iterations after which to apply the Thermostat functionality. |
| T_target | The target temperature \( T_{target} \) of the system. |
| delta_T | The maximum temperature difference \( \Delta T \) in one Thermostat application. |
| initBrownianMotion | Determines whether or not to initialize the velocities with Brownian Motion. |
| nanoFlow | Determines whether the thermostat is used for the nano-scale flow simulation. |
| limitScaling | Determines if the Thermostat should apply gradual or direct velocity scaling. |
| void Thermostat::initializeBrownianMotion | ( | ) |
Initialize the Particle velocities with Brownian Motion.
Assuming a Particle does not have an initial velocity, in order for the system to have a non-zero temperature, the velocity for any given Particle \( i \) is calculated using a Maxwell-Boltzmann distribution with the factor
\[ f_i = \sqrt{\frac{T_{init}}{m_i}}. \]
| bool Thermostat::operator== | ( | const Thermostat & | other | ) | const |
Overload of the equality operator. Checks if two Thermostat objects have the same values.
Does not check if both objects reference the same ParticleContainer.
| other | The other Thermostat to check the values against. |
| void Thermostat::updateSystemTemp | ( | int | currentStep | ) |
Updates the system temperature after the number of iterations specified inside the Thermostat object.
For nanoscale simulations, the thermal motion of the particles inside the system are taken into account.
| currentStep | The current iteration of the simulation, used to determine whether or not to apply the thermostat. In the first iteration, if initBrownianMotion is set, the Particle velocities will be initialized with Brownian Motion. Otherwise, nothing is done in the first iteration. |
|
private |
Average velocity of the system.
|
private |
The maximum temperature difference \( \Delta T \) in one Thermostat application (default: \( \infty \)).
If no temperature difference is specified (i.e. if the value is defaulted to INFINITY), the temperature is set directly in one Thermostat application.
|
private |
The dimensions for which the Thermostat temperature regulation should be applied (default: 2).
|
private |
Determines whether or not to initialize the velocities with Brownian Motion (default: on).
|
private |
The kinetic energy \( E_{kin} \) of the active simulation particles (default: 0).
|
private |
Determines if the Thermostat should apply gradual velocity scaling or direct velocity scaling (default: direct).
|
private |
The number of simulation iterations after which to apply the Thermostat functionality (default: 1000).
Must be specified when initializing a Thermostat.
|
private |
Determines whether the thermostat is used for the nano-scale flow simulation.
|
private |
A reference to the Particle system.
|
private |
The scaling factor \( \beta \) by which to scale the Particle velocities (default: 1).
|
private |
The starting temperature \( T_{init} \) of the system (default: 0).
Must be specified when initializing a Thermostat.
|
private |
The target temperature \( T_{target} \) of the system (default: \( T_{init} \)).
If no target temperature is given in the input, the target temperature is set to \( T_{init} \).
|
private |
The Temperature \( T \) of the system (default: 0).