Page MenuHomec4science

stimulation_temperature.cc
No OneTemporary

File Metadata

Created
Mon, Oct 28, 18:54

stimulation_temperature.cc

/**
* @file stimulation_temperature.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Srinivasa Babu Ramisetti <srinivasa.ramisetti@epfl.ch>
*
* @date Wed Jul 09 21:59:47 2014
*
* @brief Set a given temperature to a set of DOFs
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale is free software: you can redistribute it and/or modify it
* under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* LibMultiScale is distributed in the hope that it will be useful, but
* WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "stimulation_temperature.hh"
#include "compute_ekin.hh"
#include "lib_continuum.hh"
#include "lib_dd.hh"
#include "lib_md.hh"
#include "lm_common.hh"
#include <random>
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
/* LMDESC TEMPERATURE
This stimulator sets initial velocity to input a temperature.
*/
/* LMEXAMPLE STIMULATION TEMPERATURE TEMP 100 SEED 32 */
/* LMEXAMPLE STIMULATION TEMPERATURE FLUX_FLAG FLUX 1 SEED 32 */
/* LMHERITANCE action_interface */
inline void StimulationTemperature::declareParams() {
StimulationInterface::declareParams();
/* LMKEYWORD TEMP
Set the temperature desired to be set
*/
this->parseKeyword("TEMP", temperature);
/* LMKEYWORD SEED
Set the seed for the random generator
*/
this->parseKeyword("SEED", seed);
/* LMKEYWORD HEAT_RATE
Set the heat rate per node (only for finite elements)
*/
this->parseKeyword("HEAT_RATE", heat_rate_per_node, 0.);
/* LMKEYWORD FLUX_FLAG
Set the flux per node (only for finite elements)
*/
this->parseTag("FLUX_FLAG", flux_flag, false);
}
/* -------------------------------------------------------------------------- */
StimulationTemperature::StimulationTemperature(const std::string &name)
: LMObject(name), flux_flag(false){};
/* -------------------------------------------------------------------------- */
StimulationTemperature::~StimulationTemperature(){};
/* -------------------------------------------------------------------------- */
template <typename Cont>
enable_if_md<Cont> StimulationTemperature::stimulate(Cont &cont) {
constexpr UInt Dim = Cont::Dim;
std::default_random_engine generator(seed);
std::normal_distribution<double> distribution;
for (auto &&at : cont) {
auto vel = at.velocity();
for (UInt i = 0; i < Dim; ++i)
vel[i] = distribution(generator);
}
ComputeEKin compute_ekin("ComputeEkin:" + this->getID());
compute_ekin.build(cont);
Real T_ = compute_ekin.get(1);
Real alpha = sqrt(temperature / T_);
for (auto &&at : cont) {
DUMP("procede a la stimulation de l'atome a la position " << at, DBG_INFO);
at.velocity() *= alpha;
}
compute_ekin.build(cont);
T_ = compute_ekin.get(1);
}
/* -------------------------------------------------------------------------- */
template <typename Cont>
enable_if_mesh<Cont> StimulationTemperature::stimulate(Cont &cont) {
if (!flux_flag) {
for (auto &&n : cont) {
n.temperature() = this->temperature;
}
} else {
for (auto &&n : cont) {
n.externalHeatRate() = this->heat_rate_per_node;
}
}
}
/* -------------------------------------------------------------------------- */
DECLARE_STIMULATION_MAKE_CALL(StimulationTemperature);
__END_LIBMULTISCALE__

Event Timeline