-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsphericalVertex.cpp
More file actions
145 lines (131 loc) · 5.43 KB
/
sphericalVertex.cpp
File metadata and controls
145 lines (131 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "std_include.h" // std library includes, definition of scalar, etc.. has a "using namespace std" in it, because I'm lazy
//we'll use TCLAP as our command line parser
#include <tclap/CmdLine.h>
#include "cuda_profiler_api.h"
#include "functions.h"
#include "profiler.h"
#include "gpuarray.h"
#include "periodicBoundaryConditions.h"
#include "simulation.h"
#include "simpleModel.h"
#include "sphericalVertexModel.h"
#include "sphericalVectorialVicsek.h"
#include "baseUpdater.h"
#include "energyMinimizerFIRE.h"
#include "velocityVerlet.h"
#include "noseHooverNVT.h"
#include "brownianDynamics.h"
#include "noiseSource.h"
#include "harmonicRepulsion.h"
#include "lennardJones6_12.h"
#include "indexer.h"
#include "hyperrectangularCellList.h"
#include "neighborList.h"
#include "poissonDiskSampling.h"
#include "sphericalVoronoi.h"
#include "vectorValueNetCDF.h"
#include "simpleUtilities.h"
#include "analysisPackage.h"
using namespace std;
using namespace TCLAP;
/*!
core of spherical vertexmodel
*/
int main(int argc, char*argv[])
{
// wrap tclap in a try block
try
{
//First, we set up a basic command line parser...
// cmd("command description message", delimiter, version string)
CmdLine cmd("basic testing of dDimSim", ' ', "V0.1");
//define the various command line strings that can be passed in...
//ValueArg<T> variableName("shortflag","longFlag","description",required or not, default value,"value type",CmdLine object to add to
ValueArg<int> programSwitchArg("z","programSwitch","an integer controlling program branch",false,0,"int",cmd);
ValueArg<int> gpuSwitchArg("g","USEGPU","an integer controlling which gpu to use... g < 0 uses the cpu",false,-1,"int",cmd);
ValueArg<int> nSwitchArg("n","Number","number of particles in the simulation",false,100,"int",cmd);
ValueArg<int> maxIterationsSwitchArg("i","iterations","number of timestep iterations",false,0,"int",cmd);
ValueArg<int> fileIdxSwitch("f","file","file Index",false,-1,"int",cmd);
ValueArg<scalar> lengthSwitchArg("l","sideLength","size of simulation domain",false,10.0,"double",cmd);
ValueArg<scalar> krSwitchArg("k","springRatio","kA divided by kP",false,1.0,"double",cmd);
ValueArg<scalar> temperatureSwitchArg("t","temperature","temperature of simulation",false,.001,"double",cmd);
//allow setting of system size by either volume fraction or density (assuming N has been set)
ValueArg<scalar> p0SwitchArg("p","p0","preferred perimeter",false,3.78,"double",cmd);
ValueArg<scalar> a0SwitchArg("a","a0","preferred area per cell",false,1.0,"double",cmd);
ValueArg<scalar> rhoSwitchArg("r","rho","density",false,-1.0,"double",cmd);
ValueArg<scalar> dtSwitchArg("e","dt","timestep",false,0.001,"double",cmd);
ValueArg<scalar> v0SwitchArg("v","v0","v0",false,0.5,"double",cmd);
//parse the arguments
cmd.parse( argc, argv );
int programSwitch = programSwitchArg.getValue();
int fIdx = fileIdxSwitch.getValue();
int N = nSwitchArg.getValue();
int maximumIterations = maxIterationsSwitchArg.getValue();
scalar L = lengthSwitchArg.getValue();
scalar Temperature = temperatureSwitchArg.getValue();
scalar rho = rhoSwitchArg.getValue();
scalar dt = dtSwitchArg.getValue();
scalar v0 = v0SwitchArg.getValue();
scalar p0 = p0SwitchArg.getValue();
scalar a0 = a0SwitchArg.getValue();
scalar kr = krSwitchArg.getValue();
int gpuSwitch = gpuSwitchArg.getValue();
bool GPU = false;
if(gpuSwitch >=0)
GPU = chooseGPU(gpuSwitch);
int dim =DIMENSION;
bool reproducible = fIdx <=0 ? true : false;
noiseSource noise(reproducible);
shared_ptr<sphericalVertexModel> Configuration = make_shared<sphericalVertexModel>(N,noise,a0,p0,GPU,!GPU);
Configuration->setScalarModelParameter(kr);
shared_ptr<brownianDynamics> BD = make_shared<brownianDynamics>(reproducible);
shared_ptr<Simulation> sim = make_shared<Simulation>();
sim->setConfiguration(Configuration);
sim->addUpdater(BD,Configuration);
sim->setIntegrationTimestep(dt);
if(gpuSwitch >=0)
{
sim->setCPUOperation(false);
};
sim->setReproducible(reproducible);
int stepsPerTau = floor(1./dt);
//initialize
BD->setT(0);
Configuration->setPreferredParameters(1.0,1.0);
profiler stabProf("stabilization");
cout << "stabilization..." << endl;
for (int ii = 0; ii < maximumIterations; ++ii)
{
stabProf.start();
sim->performTimestep();
stabProf.end();
}
BD->setT(Temperature);
Configuration->setPreferredParameters(a0,p0);
cout << "initialization..." << endl;
profiler initProf("initialization ");
for (int ii = 0; ii < maximumIterations; ++ii)
{
initProf.start();
sim->performTimestep();
initProf.end();
}
dVec meanForce;
Configuration->getMeanForce(meanForce);
printf("mean force: %g %g %g\n",meanForce[0],meanForce[1],meanForce[2]);
Configuration->geoProf.setName("geometry");
Configuration->forceProf.setName("force");
Configuration->moveProf.setName("movement and topology");
Configuration->geoProf.print();
Configuration->forceProf.print();
Configuration->moveProf.print();
BD->updateProfiler.print();
stabProf.print();
initProf.print();
//
//The end of the tclap try
//
} catch (ArgException &e) // catch any exceptions
{ cerr << "error: " << e.error() << " for arg " << e.argId() << endl; }
return 0;
};