Newer
Older
// Configuration.h (2013)
// Loads .brown config file that can be shared between simulations
// To be used by GrandBrownTown to initialize its members
//
// Authors: Terrance Howward <howard33@illinois.edu>
// Justin Dufresne <jdufres1@friars.providence.edu>
//
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <algorithm> // sort
#include <cuda.h>
#include <cuda_runtime.h>
#include "useful.h" // String, Vector3
#include "BrownianParticleType.h"
#include "BaseGrid.h"
#include "OverlordGrid.h"
#include "ComputeForce.h"
#include "Reader.h"
#include "TrajectoryWriter.h"
#include "TabulatedPotential.h"
#include "TabulatedAngle.h"
// Units:
// Energy: kcal/mol (6.947694e-24 kJ)
// Temperature: Kelvin
// Time: nanoseconds
cmaffeo2
committed
// Momentum: Da * \mu m / ns
// Forward declerations
class Angle;
class Dihedral;
struct Restraint;
class Configuration {
struct compare {
bool operator()(const String& lhs, const String& rhs);
bool operator()(const Bond& lhs, const Bond& rhs);
bool operator()(const Exclude& lhs, const Exclude& rhs);
bool operator()(const Angle& lhs, const Angle& rhs);
bool operator()(const Dihedral& lhs, const Dihedral& rhs);
cmaffeo2
committed
bool operator()(const BondAngle& lhs, const BondAngle& rhs);
bool operator()(const ProductPotentialConf& lhs, const ProductPotentialConf& rhs);
Matrix3 stringToMatrix3(String s);
int readParameters(const char* config_file);
void readAngles();
void readAtoms();
cmaffeo2
committed
void addExclusion(int ind1, int ind2);
void buildExcludeMap();
cmaffeo2
committed
void readBondAngles();
cmaffeo2
committed
bool readTableFile(const String& value, int currTab);
bool readBondFile(const String& value, int currBond);
bool readAngleFile(const String& value, int currAngle);
bool readDihedralFile(const String& value, int currDihedral);
cmaffeo2
committed
bool readBondAngleFile(const String& value, const String& bondfile1, const String& bondfile2, int currBondAngle);
// Given the numbers of each particle, populate the type list.
void populate();
void loadRestart(const char* file_name);
bool loadCoordinates(const char* file_name);
int countRestart(const char* file_name);
void getDebugForce();
cmaffeo2
committed
//Han-Yi Chou
bool Boltzmann(const Vector3& com_v,int N);
bool loadMomentum(const char* file_name);
void loadRestartMomentum(const char* file_name);
void Print();
void PrintMomentum();
public:
Configuration(const char * config_file, int simNum = 0, bool debug=false);
~Configuration();
cmaffeo2
committed
int find_particle_type(const char* s) const {
for (int j = 0; j < numParts; j++) {
// printf("Searching particle %d (%s) =? %s\n", j, part[j].name.val(), s);
if (strcmp(s,part[j].name.val()) == 0)
cmaffeo2
committed
return j;
cmaffeo2
committed
return -1;
}
void copyToCUDA();
// Output variables
Vector3 sysDim;
BaseGrid* sys;
// temporary variables
Vector3 origin, size, basis1, basis2, basis3;
cmaffeo2
committed
bool loadedMomentum;
eguzman6
committed
//int *type_d;
BrownianParticleType **part_d;
BaseGrid *sys_d, *kTGrid_d;
eguzman6
committed
//Bond* bonds_d;
//int2* bondMap_d;
//Exclude* excludes_d;
//int2* excludeMap_d;
//Angle* angles_d;
//Dihedral* dihedrals_d;
// number of simulations
int simNum;
// Particle variables
String* partsFromFile;
int* indices;
int numPartsFromFile;
Bond* bonds;
int numCap; // max number of particles
int num; // current number of particles
cmaffeo2
committed
int num_rb_attached_particles;
Vector3* pos; // position of each particle
cmaffeo2
committed
Vector3* momentum; //momentum of each brownian particles Han-Yi Chou
Vector3 COM_Velocity; //center of mass velocity Han-Yi Chou
int* type; // type of each particle
int* serial; // serial number of each particle
int currSerial; // the serial number of the next new particle
String* name; // name of each particle
Vector3* posLast; // used for current computation
cmaffeo2
committed
Vector3* momLast; //used for Lagevin dynamics
float timeLast; // used with posLast
float minimumSep; // minimum separation allowed with placing new particles
/* int numRB; */
/* std::vector< std::vector<RigidBody> > rbs; */
// System parameters
String outputName;
float timestep;
long int steps;
long int seed;
// String kTGridFile;
String temperatureGridFile;
cmaffeo2
committed
String inputMomentum; //Han-Yi Chou
String inputRBCoordinates;
String restartRBCoordinates;
int copyReplicaCoordinates;
cmaffeo2
committed
String restartMomentum; //Han-Yi Chou
int numberFluct;
int interparticleForce;
int tabulatedPotential;
int fullLongRange;
float kT;
float temperature;
float coulombConst;
float electricField;
float cutoff;
float pairlistDistance;
float imdForceScale;
int outputPeriod;
int outputEnergyPeriod;
int outputFormat;
float currentSegmentZ;
int numberFluctPeriod;
int decompPeriod;
int numCapFactor;
BaseGrid* kTGrid;
BaseGrid* tGrid;
BaseGrid* sigmaT;
unsigned long randoSeed;
// Other parameters.
cmaffeo2
committed
int rigidBodyGridGridPeriod;
float switchStart;
float maxInitialPot;
float initialZ;
// Particle parameters.
BrownianParticleType* part;
int numParts;
int numBonds;
int numExcludes;
int numAngles;
int numDihedrals;
cmaffeo2
committed
int numBondAngles;
int* numPartsOfType;
String partFile;
String bondFile;
String excludeFile;
String angleFile;
String dihedralFile;
cmaffeo2
committed
String bondAngleFile;
bool readBondsFromFile;
bool readExcludesFromFile;
bool readAnglesFromFile;
bool readDihedralsFromFile;
cmaffeo2
committed
bool readBondAnglesFromFile;
//String* partGridFile;
String **partGridFile;
//float* partGridFileScale;
float **partGridFileScale;
//int *numPartGridFiles;
std::map<std::string,BaseGrid> part_grid_dictionary;
std::map<std::string,BaseGrid*> part_grid_dictionary_d;
std::vector< std::vector<String> > partRigidBodyGrid;
String* partDiffusionGridFile;
String* partForceXGridFile;
String* partForceYGridFile;
String* partForceZGridFile;
String* partTableFile;
String* partReservoirFile;
int* partTableIndex0;
int* partTableIndex1;
String groupSiteFile;
int numGroupSites;
std::vector<std::vector<int>> groupSiteData;
String* bondTableFile;
int numTabBondFiles;
int2* bondMap;
Exclude* excludes;
int2* excludeMap;
String excludeRule;
int excludeCapacity;
Angle* angles;
String* angleTableFile;
int numTabAngleFiles;
Dihedral* dihedrals;
String* dihedralTableFile;
int numTabDihedralFiles;
cmaffeo2
committed
BondAngle* bondAngles;
void readProductPotentials();
String productPotentialFile;
int numProductPotentials;
bool readProductPotentialsFromFile;
ProductPotentialConf* productPotentials;
XpotMap simple_potential_ids;
std::vector<SimplePotential> simple_potentials;
cmaffeo2
committed
//Han-Yi Chou
String ParticleDynamicType;
String RigidBodyDynamicType;
String ParticleLangevinIntegrator;
// RigidBody parameters.
RigidBodyType* rigidBody;
int ParticleInterpolationType;
int RigidBodyInterpolationType;