forked from idaholab/magpie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First design of MD capability in Magpie (idaholab#367)
- Loading branch information
Sebastian Schunert
committed
Jan 30, 2019
1 parent
80c406d
commit 2822d60
Showing
16 changed files
with
871 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/**********************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ | ||
/* */ | ||
/* Copyright 2017 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/**********************************************************************/ | ||
|
||
#ifndef MDNPARTICLEAUX_H | ||
#define MDNPARTICLEAUX_H | ||
|
||
#include "AuxKernel.h" | ||
|
||
// forward declarations | ||
class MDRunBase; | ||
class MDNParticleAux; | ||
|
||
template <> | ||
InputParameters validParams<MDNParticleAux>(); | ||
|
||
class MDNParticleAux : public AuxKernel | ||
{ | ||
public: | ||
MDNParticleAux(const InputParameters & params); | ||
virtual ~MDNParticleAux() {} | ||
|
||
virtual Real computeValue(); | ||
|
||
protected: | ||
const MDRunBase & _md_uo; | ||
}; | ||
|
||
#endif // MDNPARTICLEAUX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/**********************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ | ||
/* */ | ||
/* Copyright 2017 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/**********************************************************************/ | ||
|
||
#ifndef LAMMPSFILERUNNER_H | ||
#define LAMMPSFILERUNNER_H | ||
|
||
#include "MDRunBase.h" | ||
|
||
class LAMMPSFileRunner; | ||
|
||
template <> | ||
InputParameters validParams<LAMMPSFileRunner>(); | ||
|
||
/** | ||
* Reads lammps dump files to emulate MD simulation | ||
*/ | ||
class LAMMPSFileRunner : public MDRunBase | ||
{ | ||
public: | ||
LAMMPSFileRunner(const InputParameters & parameters); | ||
|
||
virtual void initialize() override {} | ||
virtual void execute() override {} | ||
virtual void finalize() override {} | ||
virtual void initialSetup() override; | ||
|
||
virtual void updateParticleList() override; | ||
|
||
protected: | ||
/// reads a LAMMPS file | ||
void readLAMMPSFile(FileName filename); | ||
|
||
/// reads two LAMMPS files and interpolates times | ||
void readLAMMPSFileHistory(std::pair<FileName, FileName> filenames, | ||
std::pair<Real, Real> timestamps, | ||
Real current_time); | ||
|
||
/// helper function that finds two files, one right before and one right after md_time | ||
void findBracketingLAMMPSFiles(Real md_time, | ||
std::pair<std::string, std::string> & filenames, | ||
std::pair<Real, Real> & timestamps); | ||
|
||
/// whether a sequence of input files or a single input file is read | ||
bool _time_sequence; | ||
|
||
/// name of LAMMPS file or file base if _time_sequence == true | ||
FileName _lammps_file; | ||
|
||
/// column of , y, z coordinate in LAMMPS files | ||
std::vector<unsigned int> _pos_columns; | ||
|
||
/// get velocity from file or compute it from positions | ||
bool _velocity_from_file; | ||
|
||
/// column of , y, z coordinate in LAMMPS files | ||
std::vector<unsigned int> _vel_columns; | ||
|
||
/// Conversion from FEM time to MD time_stamp | ||
Function * _time_conversion; | ||
}; | ||
|
||
#endif // LAMMPSFILERUNNER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/**********************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ | ||
/* */ | ||
/* Copyright 2017 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/**********************************************************************/ | ||
|
||
#ifndef MDRUNBASE_H | ||
#define MDRUNBASE_H | ||
|
||
#include "GeneralUserObject.h" | ||
#include "KDTree.h" | ||
#include "libmesh/bounding_box.h" | ||
|
||
class MDRunBase; | ||
class MooseMesh; | ||
|
||
template <> | ||
InputParameters validParams<MDRunBase>(); | ||
|
||
/** | ||
* Base class for molecular dynamics runs in Magpie | ||
*/ | ||
class MDRunBase : public GeneralUserObject | ||
{ | ||
public: | ||
MDRunBase(const InputParameters & parameters); | ||
|
||
void initialSetup() override; | ||
void timestepSetup() override; | ||
|
||
class MDParticles | ||
{ | ||
public: | ||
/// particle's position and history | ||
std::vector<Point> pos; | ||
|
||
/// particle's velocity | ||
std::vector<Point> vel; | ||
|
||
/// the id of particle in the MD calculation | ||
std::vector<unsigned int> id; | ||
|
||
/// the mesh element the particles are in | ||
std::vector<dof_id_type> elem_id; | ||
}; | ||
|
||
/// access to the MDParticles | ||
const MDParticles & particles() const { return _md_particles; } | ||
|
||
/// access to the element to particle map | ||
const std::vector<unsigned int> elemParticles(dof_id_type elem_id) const; | ||
|
||
protected: | ||
/// call back function to update the particle list | ||
virtual void updateParticleList() = 0; | ||
|
||
/// updates the KDTree object | ||
void updateKDTree(); | ||
|
||
/// map MDParticles to elements | ||
void mapMDParticles(); | ||
|
||
/// The Mesh we're using | ||
MooseMesh & _mesh; | ||
|
||
/// dimension of the mesh | ||
const unsigned int _dim; | ||
|
||
/// dimension of the mesh | ||
const unsigned int _nproc; | ||
|
||
/// stores bounding boxes of all other processors | ||
std::vector<BoundingBox> _bbox; | ||
|
||
/// total number of particles | ||
unsigned int _n_particles; | ||
|
||
/// number of local particles | ||
unsigned int _n_local_particles; | ||
|
||
/// stores the location of | ||
MDParticles _md_particles; | ||
|
||
/// a map from elem pointer to particles in this element | ||
std::map<dof_id_type, std::vector<unsigned int>> _elem_particles; | ||
|
||
/// A KDTree object to handle md_particles | ||
std::unique_ptr<KDTree> _kd_tree; | ||
}; | ||
|
||
#endif // MDRUNBASE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/**********************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ | ||
/* */ | ||
/* Copyright 2017 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/**********************************************************************/ | ||
|
||
#include "MDNParticleAux.h" | ||
#include "MDRunBase.h" | ||
|
||
registerMooseObject("MagpieApp", MDNParticleAux); | ||
|
||
template <> | ||
InputParameters | ||
validParams<MDNParticleAux>() | ||
{ | ||
InputParameters params = validParams<AuxKernel>(); | ||
params.addRequiredParam<UserObjectName>("user_object", "Name of MD runner UserObject"); | ||
return params; | ||
} | ||
|
||
MDNParticleAux::MDNParticleAux(const InputParameters & parameters) | ||
: AuxKernel(parameters), | ||
_md_uo(getUserObject<MDRunBase>("user_object")) | ||
{ | ||
} | ||
|
||
Real | ||
MDNParticleAux::computeValue() | ||
{ | ||
return _md_uo.elemParticles(_current_elem->id()).size(); | ||
} |
Oops, something went wrong.