Skip to content

Commit

Permalink
First design of MD capability in Magpie (idaholab#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schunert committed Jan 24, 2019
1 parent 80c406d commit 6f9c9ae
Show file tree
Hide file tree
Showing 10 changed files with 68,274 additions and 0 deletions.
67 changes: 67 additions & 0 deletions include/userobjects/LAMMPSFileRunner.h
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
87 changes: 87 additions & 0 deletions include/userobjects/MDRunBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**********************************************************************/
/* 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;
};

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
Loading

0 comments on commit 6f9c9ae

Please sign in to comment.