Skip to content

Commit

Permalink
Added Langevin thermostat, with json config features
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaunak committed Aug 14, 2022
1 parent 66dad95 commit 5713bbc
Show file tree
Hide file tree
Showing 7 changed files with 24,706 additions and 24 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
notebooks
*.txt
*.rst
*.json
.vscode
a.out
70 changes: 66 additions & 4 deletions config.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,71 @@
#ifndef CONFIG_H
#define CONFIG_H

class Config {
public:
static constexpr float samplingTemperature = 0.3;
};
#include <fstream>
#include "json.hpp"

using json = nlohmann::json;

float samplingTemperature;
std::vector<float> samplingTemperatures;
int numSteps;
int numParticles;
int outputPeriod;
std::string runType;
std::string systemName;
std::string rst;
bool isRstPresent;
float tauValue;

void setDefaultConfig() {
samplingTemperature = 0.3;
samplingTemperatures = {0.3f, 2.0f};
numSteps = 1000;
numParticles = 10;
outputPeriod = 100;
runType = "nve";
systemName = "1D_Smit";
tauValue = 0.01f;
isRstPresent = false;

}

void getConfigFromFile(std::string fileName) {

std::ifstream jsonFileObject(fileName);
json data = json::parse(jsonFileObject);

if(data.contains("temperature"))
samplingTemperature = data["temperature"];

if(data.contains("num_steps"))
numSteps = data["num_steps"];

if(data.contains("output_period"))
outputPeriod = data["output_period"];

if(data.contains("run_type"))
runType = data["run_type"];

if(data.contains("system"))
systemName = data["system"];

if(data.contains("tau"))
tauValue = data["tau"];

if(data.contains("rst")) {
isRstPresent = true;
rst = data["rst"];
}

if(data.contains("num_particles"))
numParticles = data["num_particles"];

// if(data.contains("temperatures"))
// samplingTemperatures = data["temperatures"];


}


#endif
Loading

0 comments on commit 5713bbc

Please sign in to comment.