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
authored and
Sebastian Schunert
committed
Feb 4, 2019
1 parent
8bd81b0
commit e760d9c
Showing
23 changed files
with
981 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,14 @@ | ||
# MDNParticleAux | ||
|
||
!syntax description /AuxKernels/MDNParticleAux | ||
|
||
Injects the number of MD particles per element computed by | ||
MD runner object into an auxiliary variable. | ||
|
||
!syntax parameters /AuxKernels/MDNParticleAux | ||
|
||
!syntax inputs /AuxKernels/MDNParticleAux | ||
|
||
!syntax children /AuxKernels/MDNParticleAux | ||
|
||
!bibtex bibliography |
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,21 @@ | ||
# LAMMPSFileRunner | ||
|
||
`LAMMPSFileRunner` reads in LAMMPS dumps file and maps them on an FEM mesh. | ||
The `time_sequence` parameter determines if a sequence of LAMMPS files is read | ||
or a single file is loaded and used throughout. If a sequence of files is used, | ||
the `lammps_file` parameter should contain the file base, e.g. `path/to/file/filebase` | ||
if the files are called `path/to/file/filebase.<time>.xyz`. | ||
|
||
Time conversion from FEM time to LAMMPS time is facilitated by the `time_conversion` | ||
parameter that accepts a MOOSE function object. Denoting FEM time by `t` and LAMMPS time | ||
by `T`, `time_conversion` is a function `T = F(t)`. | ||
|
||
!syntax description /UserObjects/LAMMPSFileRunner | ||
|
||
!syntax parameters /UserObjects/LAMMPSFileRunner | ||
|
||
!syntax inputs /UserObjects/LAMMPSFileRunner | ||
|
||
!syntax children /UserObjects/LAMMPSFileRunner | ||
|
||
!bibtex bibliography |
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,62 @@ | ||
/**********************************************************************/ | ||
/* 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; | ||
class Function; | ||
|
||
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 x, y, z coordinate in LAMMPS files | ||
std::vector<unsigned int> _pos_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,96 @@ | ||
/**********************************************************************/ | ||
/* 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 | ||
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<unique_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(unique_id_type elem_id) const; | ||
|
||
/// List of quantities to get from MD simulation | ||
MultiMooseEnum getMDQuantities() 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<unique_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,34 @@ | ||
/**********************************************************************/ | ||
/* 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"); | ||
params.addClassDescription("Injects the number of MD particles from MDRunBase object user_object " | ||
"into auxiliary variable."); | ||
return params; | ||
} | ||
|
||
MDNParticleAux::MDNParticleAux(const InputParameters & parameters) | ||
: AuxKernel(parameters), _md_uo(getUserObject<MDRunBase>("user_object")) | ||
{ | ||
} | ||
|
||
Real | ||
MDNParticleAux::computeValue() | ||
{ | ||
return _md_uo.elemParticles(_current_elem->unique_id()).size(); | ||
} |
Oops, something went wrong.