Page MenuHomec4science

domain_lammps_dynamic.cc
No OneTemporary

File Metadata

Created
Fri, Sep 27, 22:17

domain_lammps_dynamic.cc

/**
* @file domain_lammps_dynamic.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Jaehyun Cho <jaehyun.cho@epfl.ch>
* @author Srinivasa Babu Ramisetti <srinivasa.ramisetti@epfl.ch>
*
* @date Tue Jan 21 09:03:57 2014
*
* @brief This is the generic LAMMPS model capable of explicit dynamics
*
* @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/>.
*
*/
/* -------------------------------------------------------------------------- */
#define TIMER
//#define CHECK_STABILITY
#define VMAX 1e-2
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
#include "lammps_common.hh"
#include "domain_lammps_dynamic.hh"
#include "import_lammps.hh"
#include "trace_atom.hh"
#include "communicator.hh"
/* -------------------------------------------------------------------------- */
// LAMMPS include files
#include "integrate.h"
#include "pair.h"
#include "bond.h"
#include "angle.h"
#include "dihedral.h"
#include "improper.h"
#include "kspace.h"
#include "input.h"
#include "change_box.h"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template <UInt Dim>
void DomainLammpsDynamic<Dim>::init(){
this->update->whichflag = 1;
LAMMPS_NS::LAMMPS::init();
this->update->integrate->setup();
this->initDOFs();
this->atoms.getRefManager().setState(true);
}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
DomainLammpsDynamic<Dim>::DomainLammpsDynamic(DomainID ID,CommGroup GID):
DomainLammps<Dim>(ID,GID) {
}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
void DomainLammpsDynamic<Dim>::performStep1(){
DomainLammps<Dim>::performStep1();
VIEW_ATOM(RefLammps<Dim>);
STARTTIMER("AtomStepPosition");
this->update->ntimestep++;
//this->update->eflag_global++; //to print out thermo values
//this->update->vflag_global++; //to print out thermo values
this->update->integrate->ev_set(this->update->ntimestep);
this->modify->initial_integrate(0);
this->echangeAtomes();
STOPTIMER("AtomStepPosition");
VIEW_ATOM(RefLammps<Dim>);
#ifdef CHECK_STABILITY
UInt nlocal = atom->nlocal;
UInt nb_colded = 0;
for (UInt i = 0 ; i < nlocal ; ++i){
Real vx = atom->v[i][0];
Real vy = atom->v[i][1];
Real vz = atom->v[i][2];
Real v2 = vx*vx+vy*vy+vz*vz;
if (v2 > VMAX*VMAX){
++nb_colded;
Real vnew = VMAX/sqrt(v2);
atom->v[i][0] *= vnew;
atom->v[i][1] *= vnew;
atom->v[i][2] *= vnew;
// atom->f[i][0] = 0;
// atom->f[i][1] = 0;
// atom->f[i][2] = 0;
}
}
// if (nb_colded) DUMP("simulation getting unstable, colding it artificially (nb_colded = " << nb_colded << ")",DBG_MESSAGE);
#endif
this->atoms.incRelease();
}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
void DomainLammpsDynamic<Dim>::performStep3(){
VIEW_ATOM(RefLammps<Dim>);
DUMP("AtomStepVelocities x " << this->atom->x,DBG_INFO);
STARTTIMER("AtomStepVelocities");
this->modify->final_integrate();
if (this->modify->n_end_of_step) this->modify->end_of_step();
if (LAMMPS_NS::LAMMPS::output->next == this->update->ntimestep) {
this->timer->stamp();
LAMMPS_NS::LAMMPS::output->write(this->update->ntimestep);
this->timer->stamp(TIME_OUTPUT);
}
STOPTIMER("AtomStepVelocities");
VIEW_ATOM(RefLammps<Dim>);
this->atoms.incRelease();
}
/* -------------------------------------------------------------------------- */
template <UInt Dim>
void DomainLammpsDynamic<Dim>::performStep2(){
if (!Communicator::getCommunicator().amIinGroup(this->getGroupID())) return;
VIEW_ATOM(RefLammps<Dim>);
STARTTIMER("AtomStepForces");
UInt eflag,vflag;
eflag = this->update->integrate->eflag;
vflag = this->update->integrate->vflag;
this->force_clear(vflag);
if (this->modify->n_pre_force) this->modify->pre_force(vflag);
this->timer->stamp();
if (this->atom->molecular) {
if (this->force->bond) this->force->bond->compute(eflag,vflag);
if (this->force->angle) this->force->angle->compute(eflag,vflag);
if (this->force->dihedral) this->force->dihedral->compute(eflag,vflag);
if (this->force->improper) this->force->improper->compute(eflag,vflag);
this->timer->stamp(TIME_BOND);
}
if (this->force->pair) {
this->force->pair->compute(eflag,vflag);
this->timer->stamp(TIME_PAIR);
}
if (this->force->kspace) {
this->force->kspace->compute(eflag,vflag);
this->timer->stamp(TIME_KSPACE);
}
if (this->force->newton) {
this->comm->reverse_comm();
this->timer->stamp(TIME_COMM);
}
if (this->modify->n_post_force) this->modify->post_force(vflag);
STOPTIMER("AtomStepForces");
VIEW_ATOM(RefLammps<Dim>);
this->atoms.incRelease();
}
/* -------------------------------------------------------------------------- */
template class DomainLammpsDynamic<2>;
template class DomainLammpsDynamic<3>;
__END_LIBMULTISCALE__

Event Timeline