.Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
InfoStruct.h
1 #ifndef __INFOSTRUCT_INFOSTRUCT_H__
2 #define __INFOSTRUCT_INFOSTRUCT_H__
3 
4 #include "../Constants/AtomicProperties.h"
5 #include "../Constants/Constants.h"
6 #include "rapidjson/document.h"
7 #include "rapidjson/filestream.h"
8 #include "rapidjson/prettywriter.h"
9 #include <qdir>
10 #include <algorithm>
11 #include <iostream>
12 #include <string>
13 #include <vector>
14 
15 namespace MDSimulation
16 {
22  {
23  /* Sinusoidal driver. */
24  Sinusoidal,
25  /* Constant is a constant pressure function. */
26  Constant
27  };
28 
36  class InfoStruct
37  {
38  public:
39 
40  // Convenient synonym for the number of elements.
41  static const int ET = Constants::ELEMENT_TYPES;
42 
43  std::vector<double> AtomicParts;
44 
45  // The cone angle is half the apex angle of the cone.
46  double ConeAngle;
47  double ConeTan2;
48  double ConeSolidAngle;
49  double Density;
50  double Frequency;
51  double DriverPressure;
52  double AmbientPressure;
53  double AmbientRadius;
54  double AdiabaticRadius;
55  double InitialRadius;
56  double IsothermalRadius;
57  double Temperature;
58  double InitialTime;
59  double InitialVelocity;
60  double WallTemperature;
61  double EquilibriumPressure;
62 
63  int LiquidType;
64  double LiquidDensity;
65  double LiquidSpeedOfSound;
66  double LiquidViscosity;
67  double LiquidSurfaceTension;
68 
69  double FusionBarrier;
70 
71  double AtomicDiameter[ET];
72  double AtomicDiameterSquared[ET][ET];
73 
74  double AtomicMass[ET];
75  double ReducedMass[ET][ET];
76 
77  double VWallThermal[ET];
78 
79  double BirdConstant[ET];
80 
81  DriverMode Driver;
82 
83  double CollisionThreshold;
84 
91  InfoStruct();
92 
106 
115  static InfoStruct ParseInfoStruct(const std::string& fname);
116 
122  static InfoStruct DefaultInfoStruct();
123 
127  friend std::ostream& operator<<(std::ostream& stream, const InfoStruct& matrix);
128 
129  void Read(const rapidjson::Value& reader);
130 
131  bool operator==(const InfoStruct& rhs);
132 
133  template <typename Writer>
134  void Serialize(Writer& writer) const;
135 
136  private:
137 
142  void InitTables();
143 
148  void CopyConstants();
149  };
150 
151  template <typename Writer>
152  void InfoStruct::Serialize(Writer& writer) const
153  {
154 
155  const char* liquidName = Constants::LIQUID_NAMES[LiquidType].c_str();
156 
157  writer.StartObject();
158 
159  writer.String("Environment");
160  writer.StartObject();
161 
162  // Write all of the other values.
163  writer.String("ConeAngle") , writer.Double(ConeAngle);
164  writer.String("Temperature") , writer.Double(Temperature);
165  writer.String("WallTemp") , writer.Double(WallTemperature);
166  writer.String("AmbientRadius") , writer.Double(AmbientRadius);
167  writer.String("DriverPressure") , writer.Double(DriverPressure);
168  writer.String("Frequency") , writer.Double(Frequency);
169  writer.String("InitialTime") , writer.Double(InitialTime);
170  writer.String("InitialRadius") , writer.Double(InitialRadius);
171  writer.String("InitialVelocity") , writer.Double(InitialVelocity);
172  writer.String("EquilibriumPressure") , writer.Double(EquilibriumPressure);
173  writer.String("AmbientPressure") , writer.Double(AmbientPressure);
174  writer.String("AdiabaticRadius") , writer.Double(AdiabaticRadius);
175  writer.String("IsothermalRadius") , writer.Double(IsothermalRadius);
176  if( Driver == Constant ){
177  writer.String("DriverMode") , writer.String("constant");
178  } else {
179  writer.String("DriverMode") , writer.String("sinusoidal");
180  }
181  writer.String("Liquid") , writer.String(liquidName);
182  writer.EndObject();
183  // Write the atomic parts array.
184  writer.String("Particles");
185  writer.StartObject();
186  writer.String("AtomicParts");
187  writer.StartObject();
188  int i = 0;
189  double val = 0;
190  const char *elemName;
191  for(i = 0; i < AtomicParts.size(); i++){
192  val = AtomicParts.at(i);
193  elemName = Constants::ELEMENT_NAMES[i].c_str();
194  if(val != 0){
195  writer.String(elemName), writer.Double(val);
196  }
197  }
198  writer.EndObject();
199  writer.EndObject();
200  writer.EndObject();
201  }
202 }
203 
204 #endif /* __INFO_STRUCT_H__ */
const std::string LIQUID_NAMES[LIQUID_TYPES]
Names of the possible liquids in the simulation.
Definition: Constants.h:84
InfoStruct()
Empty constructor simply initializes the values to zero.
Definition: InfoStruct.cpp:45
InfoStruct ToSimulationUnits() const
Converts the current InfoStruct to simulation units.
Definition: InfoStruct.cpp:77
static InfoStruct ParseInfoStruct(const std::string &fname)
Parser function to read in a JSON formatted text file and convert it to an InfoStruct.
Definition: InfoStruct.cpp:160
DriverMode
Possible driver modes for use in the RPK equation.
Definition: InfoStruct.h:21
friend std::ostream & operator<<(std::ostream &stream, const InfoStruct &matrix)
Make this easier to output.
Definition: InfoStruct.cpp:333
static InfoStruct DefaultInfoStruct()
Returns an InfoStruct with default values.
Definition: InfoStruct.cpp:257
const int ELEMENT_TYPES
The number of different particle types in the simulation.
Definition: AtomicProperties.h:22
Defines the structure used to hold the configurable constants of the simulation.
Definition: InfoStruct.h:36
const std::string ELEMENT_NAMES[ELEMENT_TYPES]
The names of the elements.
Definition: AtomicProperties.h:28