-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparameters.c
More file actions
904 lines (783 loc) · 22.9 KB
/
Copy pathparameters.c
File metadata and controls
904 lines (783 loc) · 22.9 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
/** @file parameters.c
*
* Load parameters from infile, in form "key value".
*/
#include "hydro.h"
/** Mostly boilerplate code for parsing lines of the form "key value"
* from a file.
*
* This was previously done through call-by-reference, but the
* parameters struct (defined in hydro.h) makes the calls a lot
* neater, even if what is being read in is a little bit more opaque
* here.
*
* For clarity, we try to keep the order in which variables are
* initialised and parsed the same as for the struct. This helps keep
* this messy repetitive code as tidy as possible.
*
* Note, empty lines and lines where the first non-space character is
* '#' are not parsed.
*
* A significant outstanding issue is the limited line length due to
* our naive use of fgets, but this is unlikely to cause trouble with
* the sort of parameters we are using.
*/
void get_parameters(char *infile, hydro_params *p)
{
int set_dx = 0;
int set_dt = 0;
int set_Lx = 0;
int set_Ly = 0;
int set_Lz = 0;
int set_steps = 0;
int set_Cav = 0;
int set_C = 0;
int set_alpha = 0;
int set_gamma = 0;
int set_lambda = 0;
int set_gstar = 0;
int set_T0 = 0;
int set_Tconst = 0;
int set_interval = 0;
int set_fftinterval = 0;
int set_silointerval = 0;
int set_silosliceinterval =0;
int set_checkpointinterval = 0;
int set_siloslicecoord=0;
int set_fftoptions = 0;
int set_uetcstart = 0;
int set_initial = 0;
int set_gwsource = 0;
int set_metricstart = 0;
int set_silodir = 0;
int set_checkpointdir = 0;
int set_initpsfile = 0;
int set_initpsbins = 0;
int set_nucleation = 0;
int set_maxattempts = 0;
int set_bubbles = 0;
int set_R_critical = 0;
int set_phimin = 0;
int set_scale = 0;
int set_T_central = 0;
int set_sphere_radius = 0;
int set_seed = 0;
char key[100];
char value[100];
char option[2800];
char total[3000];
int ret;
char *retptr;
FILE *fp;
int i;
if(access(infile, R_OK) != 0) {
printf0(*p, "Cannot read parameter file: %s\n", infile);
die(-1);
}
fp = fopen(infile,"r");
while(!feof(fp)) {
// gets is dodgy, fgets less so
retptr = fgets(total,2997,fp);
// probably EOF
if(retptr == NULL)
continue;
// Not handled gracefully
if(index(total,'\n') == NULL) {
printf0(*p,"Line too long!\n");
continue;
}
strcpy(key,"");
strcpy(value,"");
strcpy(option,"");
ret = sscanf(total,"%99s%99s%2799s",key,value,option);
// Not of the form "<key> <value>"
// -- line is blank
if((ret == EOF))
continue;
// Not of the form "<key> <value>"
// -- other reason
if (ret < 2) {
// Get rid of the newline
// -- doesn't leak memory, we're on the stack
*(index(total, '\n')) = '\0';
printf0(*p,"Unable to parse input line: \"%s\"\n", total);
continue;
}
// Comment
if(key[0] == '#') {
continue;
}
// Check for parameters (in order)
if(!strcasecmp(key,"dx")) {
p->dx = strtof(value,NULL);
set_dx = 1;
}
else if(!strcasecmp(key,"dt")) {
p->dt = strtof(value,NULL);
set_dt = 1;
}
else if(!strcasecmp(key,"Lx")) {
p->Lx = strtol(value,NULL,10);
set_Lx = 1;
}
else if(!strcasecmp(key,"Ly")) {
p->Ly = strtol(value,NULL,10);
set_Ly = 1;
}
else if(!strcasecmp(key,"Lz")) {
p->Lz = strtol(value,NULL,10);
set_Lz = 1;
}
else if(!strcasecmp(key,"steps")) {
p->steps = strtol(value,NULL,10);
set_steps = 1;
}
else if(!strcasecmp(key,"Cav")) {
p->Cav = strtof(value,NULL);
set_Cav = 1;
}
else if(!strcasecmp(key,"C")) {
p->C = strtof(value,NULL);
set_C = 1;
}
else if(!strcasecmp(key,"alpha")) {
p->alpha = strtof(value,NULL);
set_alpha = 1;
}
else if(!strcasecmp(key,"gamma")) {
p->gamma = strtof(value,NULL);
set_gamma = 1;
}
else if(!strcasecmp(key,"lambda")) {
p->lambda = strtof(value,NULL);
set_lambda = 1;
}
else if(!strcasecmp(key,"gstar")) {
p->gstar = strtof(value,NULL);
set_gstar = 1;
}
else if(!strcasecmp(key,"T0")) {
p->T0 = strtof(value,NULL);
set_T0 = 1;
}
else if(!strcasecmp(key,"Tconst")) {
p->Tconst= strtof(value,NULL);
set_Tconst = 1;
}
else if(!strcasecmp(key,"interval")) {
p->interval = strtol(value,NULL,10);
set_interval = 1;
}
else if(!strcasecmp(key,"fftinterval")) {
p->fftinterval = strtol(value,NULL,10);
set_fftinterval = 1;
}
else if(!strcasecmp(key,"silointerval")) {
p->silointerval = strtol(value,NULL,10);
set_silointerval = 1;
}
else if(!strcasecmp(key,"silosliceinterval")) {
p->silosliceinterval = strtol(value,NULL,10);
set_silosliceinterval = 1;
}
else if(!strcasecmp(key,"checkpointinterval")) {
p->checkpointinterval = strtol(value,NULL,10);
set_checkpointinterval = 1;
}
else if(!strcasecmp(key,"siloslicecoord")) {
p->siloslicecoord = strtol(value,NULL,10);
set_siloslicecoord = 1;
}
else if(!strcasecmp(key,"uetcstart")) {
if(!strcasecmp(value,"scalar")){
p->uetcstart = -1;
p->uetcscalar = 1;
p->uetcbrokenthresh = strtof(option,NULL);
}
else{
p->uetcscalar = 0;
p->uetcbrokenthresh = -1;
p->uetcstart = strtol(value,NULL,10);
}
set_uetcstart = 1;
}
else if(!strcasecmp(key,"bubbles")) {
p->bubbles = strtol(value,NULL,10);
set_bubbles = 1;
}
else if(!strcasecmp(key,"R_critical")) {
p->R_critical = strtof(value,NULL);
set_R_critical = 1;
}
else if(!strcasecmp(key,"phimin")) {
p->phimin = strtof(value,NULL);
set_phimin = 1;
}
else if(!strcasecmp(key,"scale")) {
p->scale = strtof(value,NULL);
set_scale = 1;
}
else if(!strcasecmp(key,"T_central")) {
p->T_central = strtof(value,NULL);
set_T_central = 1;
}
else if(!strcasecmp(key,"sphere_radius")) {
p->sphere_radius = strtof(value,NULL);
set_sphere_radius = 1;
}
else if(!strcasecmp(key,"initial")) {
if(!strcasecmp(value, "shocktube")) {
p->initial = INIT_SHOCK_TUBE;
} else if(!strcasecmp(value, "bubble")) {
p->initial = INIT_BUBBLE;
} else if(!strcasecmp(value, "initps")) {
p->initial= INIT_PS;
} else if(!strcasecmp(value, "initfs")) {
p->initial= INIT_FLUID_SPHERE;
} else {
printf0(*p, "warning, unrecognised value for initial"
" (%s); defaulting to bubble.\n", value);
p->initial = INIT_BUBBLE;
}
set_initial = 1;
}
else if(!strcasecmp(key,"fftoptions")) {
if(!strcasecmp(value, "all")) {
p->fft_scalars = 1;
p->fft_vel = 1;
p->fft_J = 1;
p->fft_X = 1;
p->fft_gw = 1;
p->fft_shst = 1;
} else if(!strcasecmp(value,"none")) {
p->fft_scalars = 0;
p->fft_vel = 0;
p->fft_J = 0;
p->fft_X = 0;
p->fft_gw = 0;
p->fft_shst = 0;
} else if(!strcasecmp(value,"list")) {
char *curr = strtok(option,",");
p->fft_scalars = 0;
p->fft_vel = 0;
p->fft_J = 0;
p->fft_X = 0;
p->fft_gw = 0;
p->fft_shst = 0;
while (curr != NULL){
if(!strcasecmp(curr,"scalars")){
p->fft_scalars = 1;
} else if(!strcasecmp(curr,"vel")){
p->fft_vel = 1;
} else if(!strcasecmp(curr,"J")){
p->fft_J = 1;
} else if(!strcasecmp(curr,"X")){
p->fft_X = 1;
} else if(!strcasecmp(curr,"gw")){
p->fft_gw = 1;
} else if(!strcasecmp(curr,"shst")){
p->fft_shst = 1;
} else {
printf0(*p,"warning, unrecognised fftoption: (%s),"
" ignoring. \n", curr);
}
curr = strtok(NULL, ",");
}
} else {
printf0(*p, "warning, unrecognised value for fft_options"
" (%s); giving up!\n", value);
die(123);
}
set_fftoptions = 1;
}
else if(!strcasecmp(key,"gwsource")) {
if(!strcasecmp(value, "both")) {
p->gwsource = GW_BOTH;
} else if(!strcasecmp(value, "field")) {
p->gwsource = GW_FIELD;
} else if(!strcasecmp(value, "fluid")) {
p->gwsource = GW_FLUID;
} else {
printf0(*p, "warning, unrecognised value for gwsource"
" (%s); defaulting to both.\n", value);
p->gwsource = GW_BOTH;
}
set_gwsource = 1;
}
else if(!strcasecmp(key,"metricstart")) {
p->metricstart = strtol(value,NULL,10);
set_metricstart = 1;
}
else if(!strcasecmp(key,"nucleation")) {
if(!strcasecmp(value, "off")) {
p->nucleation = NUC_OFF;
} else if(!strncasecmp(value, "list", 4)) {
p->nucleation = NUC_LIST;
char *curr = option;
// printf0(*p,"Curr is %s\n", curr);
char *next = curr;
p->n_nucsteps = 1;
for(i=0;i<strlen(curr);i++) {
if( curr[i] == ',')
p->n_nucsteps++;
}
// printf0(*p,"nucsteps is %d\n", p->n_nucsteps);
i = 0;
p->nucsteps = (int *)malloc((p->n_nucsteps)*sizeof(int));
while(strlen(curr) && strlen(next)) {
p->nucsteps[i] = strtol(curr,&next,10);
// printf0(*p,"bubble at step %d, next is %s\n",
// p->nucsteps[i],next);
curr = next+sizeof(char);
// printf0(*p,"strlen next is %d and curr is %d\n",
// strlen(next), strlen(curr));
i++;
}
// Just in case, bubble sort the list
int sorted = 0;
while(!sorted) {
sorted = 1;
for(i = 0; i < (p->n_nucsteps-1); i++) {
if(p->nucsteps[i+1] < p->nucsteps[i]) {
int temp = p->nucsteps[i+1];
p->nucsteps[i+1] = p->nucsteps[i];
p->nucsteps[i] = temp;
printf0(*p, "Bubble sort iteration necessary!\n");
sorted = 0;
}
}
}
} else if(!strncasecmp(value, "file", 4)) {
p->nucleation = NUC_FILE;
if(access(option,R_OK) != 0) {
printf0(*p ,"Unable to read nucleation file \"%s\", giving up!\n",
option);
die(123);
}
FILE *nucfile = fopen(option,"r");
p->n_nucsteps = 0;
int temp_time;
int still_reading = 1;
while(!feof(nucfile) && still_reading) {
still_reading = fscanf(nucfile,"%d",&temp_time);
if(still_reading == 1) {
p->n_nucsteps++;
}
}
printf0(*p, "Looks like there are %d bubbles in %s\n",
p->n_nucsteps, option);
rewind(nucfile);
p->nucsteps = (int *)malloc((p->n_nucsteps)*sizeof(int));
int i;
for(i=0; i<p->n_nucsteps; i++)
still_reading = fscanf(nucfile,"%d",&p->nucsteps[i]);
fclose(nucfile);
// Just in case, bubble sort the list
int sorted = 0;
while(!sorted) {
sorted = 1;
for(i = 0; i < (p->n_nucsteps-1); i++) {
if(p->nucsteps[i+1] < p->nucsteps[i]) {
int temp = p->nucsteps[i+1];
p->nucsteps[i+1] = p->nucsteps[i];
p->nucsteps[i] = temp;
printf0(*p, "Bubble sort iteration necessary!\n");
sorted = 0;
}
}
}
}
else if(!strncasecmp(value, "locfile", 4)) {
p->nucleation = NUC_FILE_LOC;
if(access(option,R_OK) != 0) {
printf0(*p ,"Unable to read nucleation file \"%s\", giving up!\n",
option);
die(123);
}
FILE *nucfile = fopen(option,"r");
p->n_nucsteps = 0;
int temp_time, temp_x, temp_y, temp_z;
int still_reading = 1;
while(!feof(nucfile) && still_reading) {
still_reading = fscanf(nucfile,"%d %d %d %d\n", &temp_time,
&temp_x, &temp_y, &temp_z);
if(still_reading == 4) {
p->n_nucsteps++;
}
}
printf0(*p, "Looks like there are %d bubbles in %s\n",
p->n_nucsteps, option);
rewind(nucfile);
p->nucsteps = (int *)malloc((p->n_nucsteps)*sizeof(int));
p->nuclocs = (int **)malloc((p->n_nucsteps)*sizeof(int *));
p->nuclocs[0] = (int *)malloc(p->n_nucsteps*3*sizeof(int));
int i;
for(i=0; i<p->n_nucsteps; i++)
p->nuclocs[i] = (*p->nuclocs + i * 3);
for(i=0; i<p->n_nucsteps; i++)
still_reading = fscanf(nucfile,"%d %d %d %d\n",
&p->nucsteps[i], &p->nuclocs[i][0],
&p->nuclocs[i][1], &p->nuclocs[i][2]);
fclose(nucfile);
// Just in case, bubble sort the list
int sorted = 0;
int j = 0;
while(!sorted) {
sorted = 1;
for(i = 0; i < (p->n_nucsteps-1); i++) {
if(p->nucsteps[i+1] < p->nucsteps[i]) {
int temp = p->nucsteps[i+1];
p->nucsteps[i+1] = p->nucsteps[i];
p->nucsteps[i] = temp;
for(j = 0; j < 3; j++){
temp = p->nuclocs[i][j];
p->nuclocs[i+1][j] = p->nuclocs[i][j];
p->nuclocs[i][j] = temp;
}
printf0(*p, "Bubble sort iteration necessary!\n");
sorted = 0;
}
}
}
}
else {
printf0(*p ,"Unrecognised nucleation type (%s), giving up!\n",
value);
die(123);
}
set_nucleation = 1;
}
else if(!strcasecmp(key,"maxattempts")) {
p->maxattempts = strtol(value,NULL,10);
set_maxattempts = 1;
}
else if(!strcasecmp(key,"silodir")) {
if(strlen(value) > 500)
printf0(*p,
"Warning: silodir name \"%s\" may be too long!\n",
value);
strncpy(p->silodir, value, 500);
set_silodir = 1;
}
else if(!strcasecmp(key,"checkpointdir")) {
if(strlen(value) > 500)
printf0(*p,
"Warning: checkpointdir name \"%s\" may be too long!\n",
value);
strncpy(p->checkpointdir, value, 500);
set_checkpointdir = 1;
}
else if(!strcasecmp(key,"initpsfile")) {
if(access(value, R_OK) != 0) {
printf0(*p ,"Unable to read initial power spectrum file \"%s\". will"
"give up if initial is initps.\n",
value);
// Don't want to die as if not actually doing initps run
// want to supply file.
}
else{
if(strlen(value) > 500)
printf0(*p,
"Warning: initpsfile name \"%s\" may be too long!\n",
value);
strncpy(p->initpsfile, value, 500);
if(!strcasecmp(option,"rot")) {
printf0(*p,
"Treating initpsfile as ROT power\n");
p->initpsfile_type = INITPSFILE_ROT;
} else if(!strcasecmp(option,"div")) {
printf0(*p,
"Treating initpsfile as DIV power\n");
p->initpsfile_type = INITPSFILE_DIV;
} else if(!strcasecmp(option,"all")) {
printf0(*p,
"Treating initpsfile as ALL power\n");
p->initpsfile_type = INITPSFILE_ALL;
} else {
printf0(*p,
"Unrecognised option to initpsfile;"
"treating initpsfile as DIV power\n");
p->initpsfile_type = INITPSFILE_DIV;
}
set_initpsfile = 1;
}
}
else if(!strcasecmp(key,"initpsbins")) {
p->initpsbins = strtol(value,NULL,10);
set_initpsbins = 1;
}
else if(!strcasecmp(key,"seed")) {
if(!p->rank){
if(!strcasecmp(value,"time")) {
p->seed = time(NULL);
} else if(!strcasecmp(value,"device")) {
FILE *ran = fopen("/dev/random","r");
if(fread(&(p->seed),sizeof(int),1,ran) != 1) {
fprintf(stderr,"Unable to read from /dev/random, using seed 0!\n");
p->seed = 0;
}
fclose(ran);
} else {
p->seed = strtol(value,NULL,10);
}
p->seed = abs(p->seed);
p->seed = reduce_sum_int(p->seed,*p);
}
else{
p->seed = 0;
p->seed = reduce_sum_int(p->seed,*p);
}
set_seed = 1;
}
}
// Check parameters were set (in order)
if(!set_dx) {
printf0(*p, "Did not set parameter \'dx\'\n");
die(100);
} else if(!set_dt) {
printf0(*p, "Did not set parameter \'dt\'\n");
die(100);
} else if(!set_Lx) {
printf0(*p, "Did not set parameter \'Lx\'\n");
die(100);
} else if(!set_Ly) {
printf0(*p, "Did not set parameter \'Ly\'\n");
die(100);
} else if(!set_Lz) {
printf0(*p, "Did not set parameter \'Lz\'\n");
die(100);
} else if(!set_steps) {
printf0(*p, "Did not set parameter \'steps\'\n");
die(100);
} else if(!set_Cav) {
printf0(*p, "Did not set parameter \'Cav\'\n");
die(100);
} else if(!set_C) {
printf0(*p, "Did not set parameter \'C\'\n");
die(100);
} else if(!set_alpha) {
printf0(*p, "Did not set parameter \'alpha\'\n");
die(100);
} else if(!set_gamma) {
printf0(*p, "Did not set parameter \'gamma\'\n");
die(100);
} else if(!set_lambda) {
printf0(*p, "Did not set parameter \'lambda\'\n");
die(100);
} else if(!set_gstar) {
printf0(*p, "Did not set parameter \'gstar\'\n");
die(100);
} else if(!set_T0) {
printf0(*p, "Did not set parameter \'T0\'\n");
die(100);
} else if(!set_Tconst) {
printf0(*p, "Did not set parameter \'Tconst\'\n");
die(100);
} else if(!set_interval) {
printf0(*p, "Did not set parameter \'interval\'\n");
die(100);
} else if(!set_fftinterval) {
printf0(*p, "Did not set parameter \'fftinterval\'\n");
die(100);
} else if(!set_silointerval) {
printf0(*p, "Did not set parameter \'silointerval\'\n");
die(100);
} else if(!set_silosliceinterval) {
printf0(*p, "Did not set parameter \'silosliceinterval\'\n");
die(100);
}else if(!set_checkpointinterval) {
printf0(*p, "Did not set parameter \'checkpointinterval\'\n");
die(100);
}else if(!set_siloslicecoord) {
printf0(*p, "Did not set parameter \'siloslicecoord\'\n");
die(100);
} else if(!set_uetcstart) {
printf0(*p, "Did not set parameter \'uetcstart\'\n");
die(100);
} else if(!set_bubbles) {
printf0(*p, "Did not set parameter \'bubbles\'\n");
die(100);
} else if(!set_scale) {
printf0(*p, "Did not set parameter \'scale\'\n");
die(100);
} else if(!set_R_critical) {
printf0(*p, "Did not set parameter \'R_critical\'\n");
die(100);
} else if(!set_T_central) {
printf0(*p, "Did not set parameter \'T_central\'\n");
die(100);
} else if(!set_sphere_radius) {
printf0(*p, "Did not set parameter \'sphere_radius\'\n");
die(100);
}else if(!set_initial) {
printf0(*p, "Did not set parameter \'initial\'\n");
die(100);
}else if(!set_fftoptions) {
printf0(*p, "Did not set parameter \'fftoptions\'\n");
die(100);
}else if(!set_gwsource) {
printf0(*p, "Did not set parameter \'gwsource\'\n");
die(100);
}else if(!set_metricstart) {
printf0(*p, "Did not set parameter \'metricstart\'\n");
die(100);
} else if(!set_nucleation) {
printf0(*p, "Did not set parameter \'nucleation\'\n");
die(100);
} else if(!set_maxattempts) {
printf0(*p, "Did not set parameter \'maxattempts\'\n");
die(100);
} else if(!set_silodir) {
printf0(*p, "Did not set parameter \'silodir\'\n");
die(100);
} else if(!set_checkpointdir) {
printf0(*p, "Did not set parameter \'checkpointdir\'\n");
die(100);
} else if(!set_seed) {
printf0(*p, "Did not set parameter \'seed\'\n");
die(100);
} else if(p->initial == INIT_PS && !set_initpsfile) {
printf0(*p, "Did not set parameter \'initpsfile\' but initps used\n");
die(100);
} else if(p->initial == INIT_PS && !set_initpsbins) {
printf0(*p, "Did not set parameter \'initpsbins\' but initps used\n");
die(100);
}
if(!p->rank) {
// Report what we found
printf0(*p,"-- Read parameters from %s:\n"
"-- dx %g, dt %g, steps %d\n"
"-- Lx %d, Ly %d, Lz %d\n"
"-- Cav %g, C %g,\n"
"-- alpha %g, gamma %g, lambda %g\n"
"-- gstar %g\n"
"-- T0 %g, Tconst %g\n"
"-- interval %d, fftinterval %d\n"
"-- silointerval %d, silosliceinterval %d,checkpointinterval %d\n"
"-- uetcstart %d\n"
"-- uetcscalar %d, uetcbrokenthresh %g\n"
"-- maxattempts %d, bubbles %d, scale %g\n"
"-- silodir \"%s\"\n"
"-- checkpointdir \"%s\"\n"
"-- seed %d\n"
"-- metricstart %d\n",
infile,
p->dx, p->dt, p->steps,
p->Lx, p->Ly, p->Lz,
p->Cav, p->C,
p->alpha, p->gamma, p->lambda,
p->gstar,
p->T0, p->Tconst,
p->interval, p->fftinterval,
p->silointerval, p->silosliceinterval, p->checkpointinterval,
p->uetcstart,
p->uetcscalar, p->uetcbrokenthresh,
p->maxattempts, p->bubbles, p->scale,
p->silodir,
p->checkpointdir,
p->seed,
p->metricstart);
if(p->initial == INIT_SHOCK_TUBE) {
printf0(*p, "-- shock tube\n");
} else if(p->initial == INIT_BUBBLE) {
printf0(*p, "-- bubble\n");
} else if(p->initial == INIT_PS) {
printf0(*p, "-- init_ps\n");
} else if(p->initial == INIT_FLUID_SPHERE) {
printf0(*p, "-- T_central %g, sphere_radius %g\n"
"-- initfs\n",
p->T_central,p->sphere_radius);
} else {
printf0(*p, "-- warning, somehow have unknown initial conds.\n");
}
printf0(*p, " -- Doing following FFTs: \n" "--");
if(p->fft_scalars)
printf0(*p, " scalars");
if(p->fft_vel)
printf0(*p, " vel");
if(p->fft_J)
printf0(*p, " J");
if(p->fft_X)
printf0(*p, " X");
if(p->fft_gw)
printf0(*p, " gw");
if(p->fft_shst)
printf0(*p, " shst");
printf0(*p, "\n");
if(p->gwsource == GW_FIELD) {
printf0(*p, "-- gws sourced by FIELD only\n");
} else if(p->gwsource == GW_FLUID) {
printf0(*p, "-- gws sourced by FLUID only\n");
} else if(p->gwsource == GW_BOTH) {
printf0(*p, "-- gws sourced by both FIELD and FLUID\n");
} else {
printf0(*p, "-- warning, somehow have unknown gwsource param\n");
}
if((p->nucleation == NUC_LIST) ||
(p->nucleation == NUC_FILE) ||
(p->nucleation == NUC_FILE_LOC)) {
printf0(*p, "<List nucleation\n");
printf0(*p, "At steps: [%d,...%d]", p->nucsteps[0],
p->nucsteps[p->n_nucsteps-1]);
// for(i=0;i<p->n_nucsteps;i++)
// printf0(*p, "%d, ", p->nucsteps[i]);
printf0(*p,"bubbles will be nucleated>\n");
} else if(p->nucleation == NUC_OFF) {
printf0(*p, "<No nucleation>\n");
} else {
printf0(*p, "<Warning, somehow have unknown nucleation process.\n");
}
}
set_bubble_parameters(p);
fclose(fp);
}
/** Set parameters relating to bubble profiles at nucleation.
*
*/
void set_bubble_parameters(hydro_params *p){
#ifdef BAG
p->phi_0 = (p->alpha + sqrt(p->alpha*p->alpha
- 4.*p->gamma*p->lambda))/(2.*p->lambda);
p->V0 = (0.5*p->gamma*p->phi_0*p->phi_0
- p->alpha*p->phi_0*p->phi_0*p->phi_0/3.
+ 0.25*p->lambda*p->phi_0*p->phi_0*p->phi_0*p->phi_0);
#else
p->V0 = -0.25*p->gamma*p->gamma*p->T0*p->T0*p->T0*p->T0/p->lambda;
#endif // BAG
#ifdef BAG
p->surface_tension = (pow(p->alpha*(p->alpha + sqrt(p->alpha*p->alpha
- 4.*p->gamma*p->lambda))
- 2*p->gamma*p->lambda, 3/2.)
/(24.*p->lambda*p->lambda*sqrt(p->lambda)));
#else
p->surface_tension = (2.0*sqrt(2.0)/81.0)*(
p->alpha*p->alpha*p->alpha
/(p->lambda*p->lambda
*sqrt(p->lambda)));
#endif // BAG
if(p->phimin <= 0.){
printf0(*p, "phimin not set, defaulting to broken phase value. \n");
#ifdef BAG
p->phimin = p->phi_0;
#else
p->phimin = (p->alpha*p->Tconst
+ sqrt((p->alpha*p->Tconst)*(p->alpha*p->Tconst)
- 4.0*p->lambda*p->gamma
*(p->Tconst*p->Tconst - p->T0*p->T0))
)/(2.0*p->lambda);
#endif // BAG
}
if(p->R_critical <= 0.){
printf0(*p, "R_critical not set, defaulting to gaussian ansatz. \n");
p->R_critical = 2.0*p->surface_tension/(Vf(*p,p->Tconst,0.0)
- Vf(*p, p->Tconst, p->phimin));
}
p->R_scaled = p->scale*p->R_critical;
printf0(*p, "-- Calculated bubble profile parameters: \n"
"-- surface_tension %g, phimin %g \n"
"-- R_critical %g, R_scaled %g \n"
"Constant potential term found \n"
"-- V0 %g \n",
p->surface_tension, p->phimin, p->R_critical, p->R_scaled,
p->V0);
}