Commit 3dbc4f78 authored by Lee-Ping's avatar Lee-Ping
Browse files

Using a const Vec3& instead of three doubles for the AnisotropicBarostat API. ...

Using a const Vec3& instead of three doubles for the AnisotropicBarostat API.  Still figuring out SWIG issues.
parent c023f4ca
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include "Force.h" #include "Force.h"
#include "Vec3.h"
#include <string> #include <string>
#include "internal/windowsExport.h" #include "internal/windowsExport.h"
...@@ -175,39 +176,21 @@ public: ...@@ -175,39 +176,21 @@ public:
/** /**
* Create a MonteCarloAnisotropicBarostat. * Create a MonteCarloAnisotropicBarostat.
* *
* @param defaultPressureX The default pressure acting on the X-axis (in bar) * @param defaultPressure The default pressure acting on each axis (in bar)
* @param defaultPressureY The default pressure acting on the Y-axis (in bar)
* @param defaultPressureZ The default pressure acting on the Z-axis (in bar)
* @param temperature the temperature at which the system is being maintained (in Kelvin) * @param temperature the temperature at which the system is being maintained (in Kelvin)
* @param frequency the frequency at which Monte Carlo pressure changes should be attempted (in time steps) * @param frequency the frequency at which Monte Carlo pressure changes should be attempted (in time steps)
* @param scaleX on/off switch for whether to scale the X axis * @param scaleX on/off switch for whether to scale the X axis
* @param scaleY on/off switch for whether to scale the Y axis * @param scaleY on/off switch for whether to scale the Y axis
* @param scaleZ on/off switch for whether to scale the Z axis * @param scaleZ on/off switch for whether to scale the Z axis
*/ */
MonteCarloAnisotropicBarostat(double defaultPressureX, double defaultPressureY, double defaultPressureZ, double temperature, int frequency = 25, bool scaleX = 1, bool scaleY = 1, bool scaleZ = 1); MonteCarloAnisotropicBarostat(const Vec3& defaultPressure, double temperature, int frequency = 25, bool scaleX = 1, bool scaleY = 1, bool scaleZ = 1);
/** /**
* Get the default pressure acting on the X-axis (in bar). * Get the default pressure (in bar).
* *
* @return the default pressure acting on the system, measured in bar. * @return the default pressure acting on the system, measured in bar.
*/ */
double getDefaultPressureX() const { Vec3 getDefaultPressure() const {
return defaultPressureX; return defaultPressure;
}
/**
* Get the default pressure acting on the Y-axis (in bar).
*
* @return the default pressure acting on the system, measured in bar.
*/
double getDefaultPressureY() const {
return defaultPressureY;
}
/**
* Get the default pressure acting on the Z-axis (in bar).
*
* @return the default pressure acting on the system, measured in bar.
*/
double getDefaultPressureZ() const {
return defaultPressureZ;
} }
/** /**
* Get the true/false flag for scaling the X-axis. * Get the true/false flag for scaling the X-axis.
...@@ -280,7 +263,7 @@ public: ...@@ -280,7 +263,7 @@ public:
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
private: private:
double defaultPressureX, defaultPressureY, defaultPressureZ; Vec3 defaultPressure;
double temperature; double temperature;
bool scaleX, scaleY, scaleZ; bool scaleX, scaleY, scaleZ;
int frequency, randomNumberSeed; int frequency, randomNumberSeed;
......
...@@ -44,8 +44,8 @@ ForceImpl* MonteCarloBarostat::createImpl() const { ...@@ -44,8 +44,8 @@ ForceImpl* MonteCarloBarostat::createImpl() const {
return new MonteCarloBarostatImpl(*this); return new MonteCarloBarostatImpl(*this);
} }
MonteCarloAnisotropicBarostat::MonteCarloAnisotropicBarostat(double defaultPressureX, double defaultPressureY, double defaultPressureZ, double temperature, int frequency, bool scaleX, bool scaleY, bool scaleZ) : MonteCarloAnisotropicBarostat::MonteCarloAnisotropicBarostat(const Vec3& defaultPressure, double temperature, int frequency, bool scaleX, bool scaleY, bool scaleZ) :
defaultPressureX(defaultPressureX), defaultPressureY(defaultPressureY), defaultPressureZ(defaultPressureZ), temperature(temperature), frequency(frequency), scaleX(scaleX), scaleY(scaleY), scaleZ(scaleZ) { defaultPressure(defaultPressure), temperature(temperature), frequency(frequency), scaleX(scaleX), scaleY(scaleY), scaleZ(scaleZ) {
setRandomNumberSeed((int) time(NULL)); setRandomNumberSeed((int) time(NULL));
} }
......
...@@ -215,9 +215,9 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) ...@@ -215,9 +215,9 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
std::map<std::string, double> MonteCarloAnisotropicBarostatImpl::getDefaultParameters() { std::map<std::string, double> MonteCarloAnisotropicBarostatImpl::getDefaultParameters() {
std::map<std::string, double> parameters; std::map<std::string, double> parameters;
parameters[MonteCarloAnisotropicBarostat::PressureX()] = getOwner().getDefaultPressureX(); parameters[MonteCarloAnisotropicBarostat::PressureX()] = getOwner().getDefaultPressure()[0];
parameters[MonteCarloAnisotropicBarostat::PressureY()] = getOwner().getDefaultPressureY(); parameters[MonteCarloAnisotropicBarostat::PressureY()] = getOwner().getDefaultPressure()[1];
parameters[MonteCarloAnisotropicBarostat::PressureZ()] = getOwner().getDefaultPressureZ(); parameters[MonteCarloAnisotropicBarostat::PressureZ()] = getOwner().getDefaultPressure()[2];
return parameters; return parameters;
} }
......
...@@ -112,7 +112,7 @@ void testIdealGas(int aniso) { ...@@ -112,7 +112,7 @@ void testIdealGas(int aniso) {
} }
MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp[0], frequency); MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp[0], frequency);
if (aniso) if (aniso)
MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(pressure, pressure, pressure, temp[0], frequency); MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(Vec3(pressure, pressure, pressure), temp[0], frequency);
system.addForce(barostat); system.addForce(barostat);
// Test it for three different temperatures. // Test it for three different temperatures.
...@@ -256,7 +256,7 @@ void testWater(int aniso) { ...@@ -256,7 +256,7 @@ void testWater(int aniso) {
system.addForce(nonbonded); system.addForce(nonbonded);
MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp, frequency); MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp, frequency);
if (aniso) if (aniso)
MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(pressure, pressure, pressure, temp, frequency); MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(Vec3(pressure, pressure, pressure), temp, frequency);
system.addForce(barostat); system.addForce(barostat);
// Simulate it and see if the density matches the expected value (1 g/mL). // Simulate it and see if the density matches the expected value (1 g/mL).
......
...@@ -112,7 +112,7 @@ void testIdealGas(int aniso) { ...@@ -112,7 +112,7 @@ void testIdealGas(int aniso) {
} }
MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp[0], frequency); MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp[0], frequency);
if (aniso) if (aniso)
MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(pressure, pressure, pressure, temp[0], frequency); MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(Vec3(pressure, pressure, pressure), temp[0], frequency);
system.addForce(barostat); system.addForce(barostat);
// Test it for three different temperatures. // Test it for three different temperatures.
...@@ -259,7 +259,7 @@ void testWater(int aniso) { ...@@ -259,7 +259,7 @@ void testWater(int aniso) {
system.addForce(nonbonded); system.addForce(nonbonded);
MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp, frequency); MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp, frequency);
if (aniso) if (aniso)
MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(pressure, pressure, pressure, temp, frequency); MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(Vec3(pressure, pressure, pressure), temp, frequency);
system.addForce(barostat); system.addForce(barostat);
// Simulate it and see if the density matches the expected value (1 g/mL). // Simulate it and see if the density matches the expected value (1 g/mL).
......
...@@ -112,7 +112,7 @@ void testIdealGas(int aniso) { ...@@ -112,7 +112,7 @@ void testIdealGas(int aniso) {
} }
MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp[0], frequency); MonteCarloBarostat* barostat = new MonteCarloBarostat(pressure, temp[0], frequency);
if (aniso) if (aniso)
MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(pressure, pressure, pressure, temp[0], frequency); MonteCarloAnisotropicBarostat* barostat = new MonteCarloAnisotropicBarostat(Vec3(pressure, pressure, pressure), temp[0], frequency);
system.addForce(barostat); system.addForce(barostat);
// Test it for three different temperatures. // Test it for three different temperatures.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment