1954
1949
if (need_reset()) {
1955
1950
PerAtomQuantity<double>::reset();
1956
const DENS_MAT & mass(atomMasses_->quantity());
1957
1951
const DENS_MAT & lambda(atomLambdas_->quantity());
1959
1953
for (int i = 0; i < quantity_.nRows(); i++) {
1960
quantity_(i,0) = sqrt(lambda(i,0)/mass(i,0));
1954
quantity_(i,0) = sqrt(lambda(i,0));
1959
//--------------------------------------------------------
1960
//--------------------------------------------------------
1961
// Class AtomicFluctuatingVelocityRescaled
1962
//--------------------------------------------------------
1963
//--------------------------------------------------------
1965
//--------------------------------------------------------
1967
//--------------------------------------------------------
1968
AtomicFluctuatingVelocityRescaled::AtomicFluctuatingVelocityRescaled(ATC_Method * atc,
1969
PerAtomQuantity<double> * atomRescaleFactor,
1970
PerAtomQuantity<double> * atomFluctuatingVelocity,
1971
AtomType atomType) :
1972
ProtectedAtomQuantity<double>(atc,atc->nsd(),atomType),
1973
atomRescaleFactor_(atomRescaleFactor),
1974
atomFluctuatingVelocity_(atomFluctuatingVelocity)
1976
InterscaleManager & interscaleManager(atc->interscale_manager());
1977
if (!atomRescaleFactor_) {
1978
atomRescaleFactor_ = interscaleManager.per_atom_quantity("AtomVelocityRescaling");
1980
if (!atomFluctuatingVelocity_) {
1981
atomFluctuatingVelocity_ = interscaleManager.per_atom_quantity("AtomicFluctuatingVelocity");
1984
atomRescaleFactor_->register_dependence(this);
1985
atomFluctuatingVelocity_->register_dependence(this);
1988
//--------------------------------------------------------
1990
//--------------------------------------------------------
1991
AtomicFluctuatingVelocityRescaled::~AtomicFluctuatingVelocityRescaled()
1993
atomRescaleFactor_->remove_dependence(this);
1994
atomFluctuatingVelocity_->remove_dependence(this);
1997
//--------------------------------------------------------
1999
//--------------------------------------------------------
2000
void AtomicFluctuatingVelocityRescaled::reset() const
2003
PerAtomQuantity<double>::reset();
2004
const DENS_MAT & factor(atomRescaleFactor_->quantity());
2005
const DENS_MAT & v(atomFluctuatingVelocity_->quantity());
2007
for (int i = 0; i < quantity_.nRows(); i++) {
2008
for (int j = 0; j < quantity_.nCols(); j++) {
2009
quantity_(i,j) = factor(i,0)*v(i,j);
2015
//--------------------------------------------------------
2016
//--------------------------------------------------------
2017
// Class AtomicCombinedRescaleThermostatError
2018
//--------------------------------------------------------
2019
//--------------------------------------------------------
2021
//--------------------------------------------------------
2023
//--------------------------------------------------------
2024
AtomicCombinedRescaleThermostatError::AtomicCombinedRescaleThermostatError(ATC_Method * atc,
2025
PerAtomQuantity<double> * atomFluctuatingMomentumRescaled,
2026
PerAtomQuantity<double> * atomMeanVelocity,
2027
PerAtomQuantity<double> * atomStreamingVelocity,
2028
PerAtomQuantity<double> * atomMass,
2029
AtomType atomType) :
2030
ProtectedAtomQuantity<double>(atc,1,atomType),
2031
atomFluctuatingMomentumRescaled_(atomFluctuatingMomentumRescaled),
2032
atomMeanVelocity_(atomMeanVelocity),
2033
atomStreamingVelocity_(atomStreamingVelocity),
2036
InterscaleManager & interscaleManager(atc->interscale_manager());
2037
if (!atomFluctuatingMomentumRescaled_) {
2038
atomFluctuatingMomentumRescaled_ = interscaleManager.per_atom_quantity("AtomFluctuatingMomentumRescaled");
2040
if (!atomMeanVelocity_) {
2041
atomMeanVelocity_ = interscaleManager.per_atom_quantity(field_to_prolongation_name(VELOCITY));
2043
if (!atomStreamingVelocity_) {
2044
atomStreamingVelocity_ = interscaleManager.per_atom_quantity("AtomLambdaMomentum");
2047
atomMass_ = interscaleManager.fundamental_atom_quantity(LammpsInterface::ATOM_MASS,
2051
atomFluctuatingMomentumRescaled_->register_dependence(this);
2052
atomMeanVelocity_->register_dependence(this);
2053
atomStreamingVelocity_->register_dependence(this);
2054
atomMass_->register_dependence(this);
2057
//--------------------------------------------------------
2059
//--------------------------------------------------------
2060
AtomicCombinedRescaleThermostatError::~AtomicCombinedRescaleThermostatError()
2062
atomFluctuatingMomentumRescaled_->remove_dependence(this);
2063
atomMeanVelocity_->remove_dependence(this);
2064
atomStreamingVelocity_->remove_dependence(this);
2065
atomMass_->remove_dependence(this);
2068
//--------------------------------------------------------
2070
//--------------------------------------------------------
2071
void AtomicCombinedRescaleThermostatError::reset() const
2074
PerAtomQuantity<double>::reset();
2075
const DENS_MAT & m(atomMass_->quantity());
2076
const DENS_MAT & p(atomFluctuatingMomentumRescaled_->quantity());
2077
const DENS_MAT & v(atomMeanVelocity_->quantity());
2078
const DENS_MAT & s(atomStreamingVelocity_->quantity());
2081
for (int i = 0; i < quantity_.nRows(); i++) {
2082
diff = s(i,0)-v(i,0);
2083
quantity_(i,0) = 2.*p(i,0)*diff + m(i,0)*diff*diff;
2084
for (int j = 1; j < p.nCols(); j++) {
2085
diff = s(i,j)-v(i,j);
2086
quantity_(i,0) += 2.*p(i,j)*diff + m(i,0)*diff*diff;