1 #include "../include/parser.h"
2 #include "../include/unit_test.h"
3 #include "../include/operators.h"
7 Grid parseArgs(int argc, char** argv){
9 // Creates initial grid class for the parameters
13 // Setting default values
14 par.store("xDim", 256);
15 par.store("yDim", 256);
16 par.store("zDim", 256);
17 par.store("omega", 0.0);
18 par.store("gammaY", 1.0);
19 par.store("gsteps", 1);
20 par.store("esteps", 1);
21 par.store("gdt", 1e-4);
22 par.store("dt", 1e-4);
23 par.store("device", 0);
24 par.store("atoms", 1);
25 par.store("read_wfc", false);
26 par.store("printSteps", 100);
27 par.store("winding", 0.0);
28 par.store("corotating", false);
29 par.store("gpe", false);
30 par.store("omegaZ", 6.283);
31 par.store("interaction",1.0);
32 par.store("laser_power",0.0);
33 par.store("angle_sweep",0.0);
34 par.store("kick_it", 0);
35 par.store("write_it", false);
36 par.store("x0_shift",0.0);
37 par.store("y0_shift",0.0);
38 par.store("z0_shift",0.0);
39 par.store("sepMinEpsilon",0.0);
40 par.store("graph", false);
41 par.store("unit_test",false);
42 par.store("omegaX", 6.283);
43 par.store("omegaY", 6.283);
44 par.store("data_dir", (std::string)"data/");
45 par.store("ramp", false);
46 par.store("ramp_type", 1);
47 par.store("dimnum", 2);
48 par.store("write_file", true);
49 par.store("fudge", 0.0);
50 par.store("kill_idx", -1);
51 par.store("mask_2d", 1.5e-4);
52 par.store("box_size", -0.01);
53 par.store("found_sobel", false);
54 par.store("energy_calc", false);
55 par.store("use_param_file", false);
56 par.store("param_file","param.cfg");
57 par.store("cyl_coord",false);
59 par.Kfn = "rotation_K";
62 par.store("conv_type", (std::string)"FFT");
63 par.store("charge", 0);
64 par.store("flip", false);
65 par.store("thresh_const", 1.0);
69 while ((opt = getopt (argc, argv,
70 "b:d:D:C:x:y:w:m:G:g:e:T:t:n:p:rQ:L:Elsi:P:X:Y:O:k:WU:V:S:ahz:H:uA:v:Z:fc:F:K:R:q:I:j:J;")) !=-1)
76 int xDim = atoi(optarg);
77 printf("Argument for x is given as %d\n",xDim);
78 par.store("xDim",(int)xDim);
83 double box_size = atof(optarg);
84 printf("Argument for box_size is given as %E\n",box_size);
85 par.store("box_size",(double)box_size);
90 double thresh_const = atof(optarg);
91 printf("Threshold constant is given as %E\n", thresh_const);
92 par.store("thresh_const",(double)thresh_const);
97 int yDim = atoi(optarg);
98 printf("Argument for y is given as %d\n",yDim);
99 par.store("yDim",(int)yDim);
104 int zDim = atoi(optarg);
105 printf("Argument for z is given as %d\n",zDim);
106 par.store("zDim",(int)zDim);
111 double omega = atof(optarg);
112 printf("Argument for OmegaRotate is given as %E\n",omega);
113 par.store("omega",(double)omega);
118 double mask_2d = atof(optarg);
119 printf("Argument for mask_2d is given as %E\n",mask_2d);
120 par.store("mask_2d",(double)mask_2d);
125 double gammaY = atof(optarg);
126 printf("Argument for gamma is given as %E\n",gammaY);
127 par.store("gammaY",(double)gammaY);
132 double gsteps = atof(optarg);
133 printf("Argument for Groundsteps is given as %E\n",gsteps);
134 par.store("gsteps",(int)gsteps);
139 double esteps = atof(optarg);
140 printf("Argument for EvSteps is given as %E\n",esteps);
141 par.store("esteps",(int)esteps);
146 double fudge = atof(optarg);
147 printf("Argument for Fudge Factor is given as %E\n",fudge);
148 par.store("fudge",fudge);
153 double gdt = atof(optarg);
154 printf("Argument for groundstate Timestep is given as %E\n",
156 par.store("gdt",(double)gdt);
161 double dt = atof(optarg);
162 printf("Argument for Timestep is given as %E\n",dt);
163 par.store("dt",(double)dt);
168 int device = atoi(optarg);
169 printf("Argument for device (Card) is given as %d\n",device);
170 par.store("device",(int)device);
175 double atoms = atof(optarg);
176 printf("Argument for atoms is given as %E\n",atoms);
177 par.store("atoms",(int)atoms);
182 std::string data_dir = par.sval("data_dir");
183 std::string param_file = filecheck(data_dir
184 + (std::string)optarg);
185 std::cout << "Input parameter file is " << param_file << '\n';
186 par.store("param_file", (std::string)param_file);
187 par.store("use_param_file", true);
192 int ramp_type = atoi(optarg);
193 printf("Ramping omega with imaginary time evolution\n");
194 par.store("ramp",true);
195 par.store("ramp_type", ramp_type);
200 printf("Reading wavefunction from file.\n");
201 std::string data_dir = par.sval("data_dir");
202 std::string infile = filecheck(data_dir + "wfc_load");
203 std::string infilei = filecheck(data_dir + "wfci_load");
204 par.store("infile", infile);
205 par.store("infilei", infilei);
206 par.store("read_wfc",true);
211 int print = atoi(optarg);
212 printf("Argument for Printout is given as %d\n",print);
213 par.store("printSteps",(int)print);
218 double l = atof(optarg);
219 printf("Vortex winding is given as : %E\n",l);
220 par.store("winding",(double)l);
225 printf("Angular momentum mode engaged\n");
226 par.store("corotating",true);
231 printf("Printing energy calculation\n");
232 par.store("energy_calc",true);
237 printf("No longer writing initial variables to file.\n");
238 par.store("write_file", false);
243 printf("Using cylindrical coordinates for B field\n");
244 par.store("cyl_coord", true);
249 int q = atoi(optarg);
250 std::cout << "Imprinting vortex with charge q " << q << '\n';
251 par.store("flip", true);
252 par.store("charge",(int)q);
257 printf("Non-linear mode engaged\n");
258 par.store("gpe",true);
263 double omegaZ = atof(optarg);
264 printf("Argument for OmegaZ is given as %E\n",omegaZ);
265 par.store("omegaZ",(double)omegaZ);
270 std::string command = "src/print_help.sh ";
271 system(command.c_str());
277 std::string command = "src/print_help.sh ";
278 command.append(optarg);
279 system(command.c_str());
285 double interaction = atof(optarg);
286 printf("Argument for interaction scaling is %E\n",interaction);
287 par.store("interaction",interaction);
292 double laser_power = atof(optarg);
293 printf("Argument for laser power is %E\n",laser_power);
294 par.store("laser_power",laser_power);
299 double omegaX = atof(optarg);
300 printf("Argument for omegaX is %E\n",omegaX);
301 par.store("omegaX",(double)omegaX);
306 double omegaY = atof(optarg);
307 printf("Argument for omegaY is %E\n",omegaY);
308 par.store("omegaY",omegaY);
313 double angle_sweep = atof(optarg);
314 printf("Argument for angle_sweep is %E\n",angle_sweep);
315 par.store("angle_sweep",angle_sweep);
320 int kick_it = atoi(optarg);
321 printf("Argument for kick_it is %i\n",kick_it);
322 par.store("kick_it",kick_it);
327 printf("Writing out\n");
328 par.store("write_it",true);
333 std::string data_dir = optarg;
334 std::cout << "Data directory is: " << data_dir << '\n';
335 par.store("data_dir", data_dir + "/");
340 double x0_shift = atof(optarg);
341 printf("Argument for x0_shift is %lf\n",x0_shift);
342 par.store("x0_shift",x0_shift);
347 std::cout << "performing all unit tests" << '\n';
348 par.store("unit_test", true);
354 double y0_shift = atof(optarg);
355 printf("Argument for y0_shift is %lf\n",y0_shift);
356 par.store("y0_shift",y0_shift);
361 std::string pot = optarg;
362 std::cout << "Chosen potential is: " << pot << '\n';
369 double sepMinEpsilon = atof(optarg);
370 printf("Argument for sepMinEpsilon is %lf\n",sepMinEpsilon);
371 par.store("sepMinEpsilon",sepMinEpsilon);
376 double z0_shift = atof(optarg);
377 printf("Argument for z0_shift is %lf\n",z0_shift);
378 par.store("z0_shift",z0_shift);
383 int dimnum = atoi(optarg);
384 printf("Argument for number of coordinates is %d\n",dimnum);
386 //setting 3d parameters
388 par.Kfn = "rotation_K3d";
391 if (par.Afn == "file"){
392 std::cout << "Finding file for Az..." << '\n';
393 par.Azfile = filecheck("src/Azgauge");
395 par.store("box_size", 2.5e-5);
398 par.store("zDim", 1);
400 par.store("dimnum",(int)dimnum);
404 // this case is special and may require reading input from a file
408 std::string field = optarg;
409 std::cout << "Chosen gauge field is: " << field << '\n';
411 // If the file gauge field is chosen, we need to make sure the
413 if (strcmp(optarg, "file") == 0){
414 std::string data_dir = par.sval("data_dir");
415 std::cout << "Finding file for Ax..." << '\n';
416 par.Axfile = filecheck(data_dir + "/Axgauge");
417 std::cout << "Finding file for Ay..." << '\n';
418 par.Ayfile = filecheck(data_dir + "/Aygauge");
419 if (par.ival("dimnum") == 3){
420 std::cout << "Finding file for Az..." << '\n';
421 par.Azfile = filecheck(data_dir + "/Azgauge");
431 printf("Graphing mode engaged\n");
432 par.store("graph",true);
438 int kill_idx = atoi(optarg);
439 printf("Argument for kill_idx is %d\n",kill_idx);
440 par.store("kill_idx",kill_idx);
448 "Option -%c requires an argument.\n", optopt);
450 else if (isprint (optopt)) {
451 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
455 "Unknown option character `\\x%x'.\n",optopt);
465 if (stat(par.sval("data_dir").c_str(), &st) == -1) {
466 mkdir(par.sval("data_dir").c_str(), 0700);
469 if (par.ival("dimnum") == 2){
470 par.store("zDim", 1);