forked from VirtualPlanetaryLaboratory/vplanet
-
Notifications
You must be signed in to change notification settings - Fork 2
/
magmoc.c
2951 lines (2619 loc) · 114 KB
/
magmoc.c
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
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/********************** MAGMOC.C **********************/
/*
* Patrick Barth, Wed May 16 13:37 PDT 2018
*
* Subroutines that control the thermal evolution of the
* magma ocean as well as the geochemistry.
*
*/
#include "vplanet.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// all variables!
void BodyCopyMagmOc(BODY *dest, BODY *src, int foo, int iNumBodies, int iBody) {
/* Primary variables */
dest[iBody].dPotTemp = src[iBody].dPotTemp;
dest[iBody].dSurfTemp = src[iBody].dSurfTemp;
dest[iBody].dSolidRadius = src[iBody].dSolidRadius;
dest[iBody].dWaterMassMOAtm = src[iBody].dWaterMassMOAtm;
dest[iBody].dWaterMassSol = src[iBody].dWaterMassSol;
dest[iBody].dOxygenMassMOAtm = src[iBody].dOxygenMassMOAtm;
dest[iBody].dOxygenMassSol = src[iBody].dOxygenMassSol;
dest[iBody].dHydrogenMassSpace = src[iBody].dHydrogenMassSpace;
dest[iBody].dOxygenMassSpace = src[iBody].dOxygenMassSpace;
dest[iBody].dCO2MassMOAtm = src[iBody].dCO2MassMOAtm;
dest[iBody].dCO2MassSol = src[iBody].dCO2MassSol;
/* Input variables */
dest[iBody].dCoreRadius = src[iBody].dCoreRadius;
dest[iBody].dWaterMassAtm = src[iBody].dWaterMassAtm;
dest[iBody].dManMeltDensity = src[iBody].dManMeltDensity;
dest[iBody].dMassFracFeOIni = src[iBody].dMassFracFeOIni;
dest[iBody].dWaterPartCoeff = src[iBody].dWaterPartCoeff;
dest[iBody].dDepthMO = src[iBody].dDepthMO;
/* Other variables Thermal model */
dest[iBody].dGravAccelSurf = src[iBody].dGravAccelSurf;
dest[iBody].dSolidRadiusLocal = src[iBody].dSolidRadiusLocal;
dest[iBody].dTransDepthSol = src[iBody].dTransDepthSol;
dest[iBody].dPrefactorA = src[iBody].dPrefactorA;
dest[iBody].dPrefactorB = src[iBody].dPrefactorB;
dest[iBody].dMeltFraction = src[iBody].dMeltFraction;
dest[iBody].dMeltFracSurf = src[iBody].dMeltFracSurf;
dest[iBody].dKinemViscos = src[iBody].dKinemViscos;
dest[iBody].dFactorDerivative = src[iBody].dFactorDerivative;
dest[iBody].dManHeatFlux = src[iBody].dManHeatFlux;
dest[iBody].dRadioHeat = src[iBody].dRadioHeat;
dest[iBody].dTidalHeat = src[iBody].dTidalHeat;
dest[iBody].dNetFluxAtmo = src[iBody].dNetFluxAtmo;
dest[iBody].dAlbedo = src[iBody].dAlbedo;
/* Other variables Volatile model */
dest[iBody].dPressWaterAtm = src[iBody].dPressWaterAtm;
dest[iBody].dPartialPressWaterAtm = src[iBody].dPartialPressWaterAtm;
dest[iBody].dPressOxygenAtm = src[iBody].dPressOxygenAtm;
dest[iBody].dPressCO2Atm = src[iBody].dPressCO2Atm;
dest[iBody].dPartialPressCO2Atm = src[iBody].dPartialPressCO2Atm;
dest[iBody].dMassMagmOcLiq = src[iBody].dMassMagmOcLiq;
dest[iBody].dMassMagmOcCry = src[iBody].dMassMagmOcCry;
dest[iBody].dWaterFracMelt = src[iBody].dWaterFracMelt;
dest[iBody].dCO2FracMelt = src[iBody].dCO2FracMelt;
dest[iBody].dFracFe2O3Man = src[iBody].dFracFe2O3Man;
dest[iBody].dOxygenMassAtm = src[iBody].dOxygenMassAtm;
dest[iBody].dAveMolarMassMan = src[iBody].dAveMolarMassMan;
/* Connection to AtmEsc */
dest[iBody].dWaterMassEsc = src[iBody].dWaterMassEsc;
dest[iBody].dOxygenMassEsc = src[iBody].dOxygenMassEsc;
/* Boolean */
dest[iBody].bManSolid = src[iBody].bManSolid;
dest[iBody].bAllFeOOxid = src[iBody].bAllFeOOxid;
dest[iBody].bLowPressSol = src[iBody].bLowPressSol;
dest[iBody].bManStartSol = src[iBody].bManStartSol;
dest[iBody].bCalcFugacity = src[iBody].bCalcFugacity;
dest[iBody].bPlanetDesiccated = src[iBody].bPlanetDesiccated;
dest[iBody].bManQuasiSol = src[iBody].bManQuasiSol;
dest[iBody].bMagmOcHaltSolid = src[iBody].bMagmOcHaltSolid;
dest[iBody].bMagmOcHaltDesicc = src[iBody].bMagmOcHaltDesicc;
dest[iBody].bEscapeStop = src[iBody].bEscapeStop;
dest[iBody].bCO2InAtmosphere = src[iBody].bCO2InAtmosphere;
/* Model indicators */
dest[iBody].iRadioHeatModel = src[iBody].iRadioHeatModel;
dest[iBody].iMagmOcAtmModel = src[iBody].iMagmOcAtmModel;
}
/**************** MAGMOC options ********************/
// read input: first function with read command
/* FeO */
void ReadMassFracFeOIni(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) { // if line num of option ge 0
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
body[iFile - 1].dMassFracFeOIni =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dMassFracFeOIni = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile >
0) { // if line num not ge 0, then if iFile gt 0, then set default.
body[iFile - 1].dMassFracFeOIni = options->dDefault;
}
}
/* Water */
void ReadWaterMassAtm(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) { // if line num of option ge 0
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) { // if input value lt 0
body[iFile - 1].dWaterMassAtm =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dWaterMassAtm = fdUnitsMass(dTmp);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile >
0) { // if line num not ge 0, then if iFile gt 0, then set default.
body[iFile - 1].dWaterMassAtm = options->dDefault;
}
}
}
/* CO2 Mass */
void ReadCO2MassMOAtm(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) { // if line num of option ge 0
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) { // if input value lt 0
body[iFile - 1].dCO2MassMOAtm =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dCO2MassMOAtm = fdUnitsMass(dTmp);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile >
0) { // if line num not ge 0, then if iFile gt 0, then set default.
body[iFile - 1].dCO2MassMOAtm = options->dDefault;
}
}
}
/* Temperature */
void ReadSurfTemp(BODY *body, CONTROL *control, FILES *files, OPTIONS *options,
SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) { // if line num of option ge 0
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
// use build-in conversion file -> distorb.c e.g.
if (dTmp < 0) { // if input value lt 0
body[iFile - 1].dSurfTemp =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dSurfTemp =
fdUnitsTemp(dTmp, control->Units[iFile].iTemp, 0);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile >
0) { // if line num not ge 0, then if iFile gt 0, then set default.
body[iFile - 1].dSurfTemp = options->dDefault;
}
}
}
/* Density */
void ReadManMeltDensity(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) { // if line num of option ge 0
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) { // if input value lt 0
body[iFile - 1].dManMeltDensity =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dManMeltDensity = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile >
0) { // if line num not ge 0, then if iFile gt 0, then set default.
body[iFile - 1].dManMeltDensity = options->dDefault;
}
}
}
/* Water partition coefficient */
void ReadWaterPartCoeff(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) { // if line num of option ge 0
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) { // if input value lt 0
body[iFile - 1].dWaterPartCoeff =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dWaterPartCoeff = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile >
0) { // if line num not ge 0, then if iFile gt 0, then set default.
body[iFile - 1].dWaterPartCoeff = options->dDefault;
}
}
}
/* Magma Ocean Depth */
void ReadDepthMO(BODY *body, CONTROL *control, FILES *files, OPTIONS *options,
SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) { // if line num of option ge 0
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) { // if input value lt 0
body[iFile - 1].dDepthMO =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dDepthMO = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile >
0) { // if line num not ge 0, then if iFile gt 0, then set default.
body[iFile - 1].dDepthMO = options->dDefault;
}
}
}
/*
* Read halt options
*/
/* Halt when mantle solidified */
void ReadHaltMantleSolidified(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
int bTmp;
AddOptionBool(files->Infile[iFile].cIn, options->cName, &bTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
control->Halt[iFile - 1].bHaltMantleSolidified = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &control->Halt[iFile - 1].bHaltMantleSolidified,
files->iNumInputs);
}
}
}
void ReadHaltMantleMeltFracLow(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
int bTmp;
AddOptionBool(files->Infile[iFile].cIn, options->cName, &bTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
control->Halt[iFile - 1].bHaltMantleMeltFracLow = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options,
&control->Halt[iFile - 1].bHaltMantleMeltFracLow,
files->iNumInputs);
}
}
}
void ReadHaltAtmDesiSurfCool(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
int bTmp;
AddOptionBool(files->Infile[iFile].cIn, options->cName, &bTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
control->Halt[iFile - 1].bHaltAtmDesiSurfCool = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &control->Halt[iFile - 1].bHaltAtmDesiSurfCool,
files->iNumInputs);
}
}
}
void ReadHaltEnterHabZone(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
int bTmp;
AddOptionBool(files->Infile[iFile].cIn, options->cName, &bTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
control->Halt[iFile - 1].bHaltEnterHabZone = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &control->Halt[iFile - 1].bHaltEnterHabZone,
files->iNumInputs);
}
}
}
void ReadHaltAllPlanetsSolid(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
int bTmp;
AddOptionBool(files->Infile[iFile].cIn, options->cName, &bTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
control->Halt[iFile - 1].bHaltAllPlanetsSolid = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &control->Halt[iFile - 1].bHaltAllPlanetsSolid,
files->iNumInputs);
}
}
}
void ReadHaltAllPlanetsDesicc(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
int bTmp;
AddOptionBool(files->Infile[iFile].cIn, options->cName, &bTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
control->Halt[iFile - 1].bHaltAllPlanetsDesicc = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &control->Halt[iFile - 1].bHaltAllPlanetsDesicc,
files->iNumInputs);
}
}
}
/*
* Read model options
*/
void ReadRadioHeatModel(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
char cTmp[OPTLEN];
AddOptionString(files->Infile[iFile].cIn, options->cName, cTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (!memcmp(sLower(cTmp), "schaefer", 4)) {
body[iFile - 1].iRadioHeatModel = MAGMOC_SCHAEFER;
} else if (!memcmp(sLower(cTmp), "none", 4)) {
body[iFile - 1].iRadioHeatModel = MAGMOC_NONE;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].iRadioHeatModel = MAGMOC_NONE;
}
}
void ReadMagmOcAtmModel(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
char cTmp[OPTLEN];
AddOptionString(files->Infile[iFile].cIn, options->cName, cTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (!memcmp(sLower(cTmp), "petit", 4)) {
body[iFile - 1].iMagmOcAtmModel = MAGMOC_PETIT;
} else if (!memcmp(sLower(cTmp), "grey", 4)) {
body[iFile - 1].iMagmOcAtmModel = MAGMOC_GREY;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].iMagmOcAtmModel = MAGMOC_GREY;
}
}
void ReadMantleQuasiSolid(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
/* This parameter cannot exist in primary file */
int lTmp = -1;
int bTmp;
AddOptionBool(files->Infile[iFile].cIn, options->cName, &bTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
body[iFile - 1].bOptManQuasiSol = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &body[iFile - 1].bOptManQuasiSol,
files->iNumInputs);
}
}
}
/* Initiatlize Input Options */
// initialize input = tell code what he is reading in
void InitializeOptionsMagmOc(OPTIONS *options, fnReadOption fnRead[]) {
/* FeO */
sprintf(options[OPT_FEO].cName, "dMassFracFeOIni"); // name of the variable
sprintf(options[OPT_FEO].cDescr,
"Initial Mass Fraction of FeO in the "
"mantle"); // description that will be shown for vplanet -h
sprintf(options[OPT_FEO].cDefault,
"BSE Earth: 0.0788"); // comment what the default value will be
sprintf(options[OPT_FEO].cDimension, "nd");
options[OPT_FEO].iType = 2; // type of the variable: double??
options[OPT_FEO].bMultiFile = 1; // can it be used in multiple files? 1 = yes
options[OPT_FEO].dNeg = 1; // is there a unit other than the SI unit? factor
// to convert between both units
options[OPT_FEO].dDefault = 0.0788; // default value
sprintf(options[OPT_FEO].cNeg, "no unit"); // specify unit (for help)
fnRead[OPT_FEO] = &ReadMassFracFeOIni; // link read function from above
/* Water */
// XXX This probably overlaps with dSurfWaterMass in AtmEsc
sprintf(options[OPT_WATERMASSATM].cName, "dWaterMassAtm");
sprintf(options[OPT_WATERMASSATM].cDescr,
"Initial Water Mass in the atmosphere");
sprintf(options[OPT_WATERMASSATM].cDefault, "1 Terrestrial Ocean");
sprintf(options[OPT_WATERMASSATM].cDimension, "mass");
options[OPT_WATERMASSATM].iType = 2;
options[OPT_WATERMASSATM].bMultiFile = 1;
options[OPT_WATERMASSATM].dNeg =
TOMASS; // for input: factor to mulitply for SI - for output: divide
// (e.g. 1/TOMASS)
options[OPT_WATERMASSATM].dDefault = TOMASS;
sprintf(options[OPT_WATERMASSATM].cNeg, "TO");
fnRead[OPT_WATERMASSATM] = &ReadWaterMassAtm;
/* CO2 */
sprintf(options[OPT_CO2MASSMOATM].cName, "dCO2MassMOAtm");
sprintf(options[OPT_CO2MASSMOATM].cDescr, "Initial CO2 mass in the system");
sprintf(options[OPT_CO2MASSMOATM].cDefault, "0 TO");
sprintf(options[OPT_CO2MASSMOATM].cDimension, "mass");
options[OPT_CO2MASSMOATM].iType = 2;
options[OPT_CO2MASSMOATM].bMultiFile = 1;
options[OPT_CO2MASSMOATM].dNeg =
TOMASS; // for input: factor to mulitply for SI - for output: divide
// (e.g. 1/TOMASS)
options[OPT_CO2MASSMOATM].dDefault = 0;
sprintf(options[OPT_CO2MASSMOATM].cNeg, "TO");
fnRead[OPT_CO2MASSMOATM] = &ReadCO2MassMOAtm;
/* Temperature */
sprintf(options[OPT_SURFTEMP].cName, "dSurfTemp");
sprintf(options[OPT_SURFTEMP].cDescr, "Initial surface temp");
sprintf(options[OPT_SURFTEMP].cDefault, "4000 K");
sprintf(options[OPT_SURFTEMP].cDimension, "temperature");
options[OPT_SURFTEMP].iType = 2;
options[OPT_SURFTEMP].bMultiFile = 1;
options[OPT_SURFTEMP].dNeg = 1;
options[OPT_SURFTEMP].dDefault = 4000;
sprintf(options[OPT_SURFTEMP].cNeg, "Kelvin");
fnRead[OPT_SURFTEMP] = &ReadSurfTemp;
/* Density */
sprintf(options[OPT_MANMELTDENSITY].cName, "dManMeltDensity");
sprintf(options[OPT_MANMELTDENSITY].cDescr, "Density of the molten mantle");
sprintf(options[OPT_MANMELTDENSITY].cDefault, "4000 kg/m^3");
sprintf(options[OPT_MANMELTDENSITY].cDimension, "mass/length^3");
options[OPT_MANMELTDENSITY].iType = 2;
options[OPT_MANMELTDENSITY].bMultiFile = 1;
options[OPT_MANMELTDENSITY].dNeg = 1;
options[OPT_MANMELTDENSITY].dDefault = 4000;
sprintf(options[OPT_MANMELTDENSITY].cNeg, "kg/m^3");
fnRead[OPT_MANMELTDENSITY] = &ReadManMeltDensity;
/* Water partition coefficient */
sprintf(options[OPT_WATERPARTCOEFF].cName, "dWaterPartCoeff");
sprintf(options[OPT_WATERPARTCOEFF].cDescr,
"Water partition coefficient between melt and solid");
sprintf(options[OPT_WATERPARTCOEFF].cDefault, "0.01");
sprintf(options[OPT_WATERPARTCOEFF].cDimension, "nd");
options[OPT_WATERPARTCOEFF].iType = 2;
options[OPT_WATERPARTCOEFF].bMultiFile = 1;
options[OPT_WATERPARTCOEFF].dNeg = 1;
options[OPT_WATERPARTCOEFF].dDefault = 0.01;
sprintf(options[OPT_WATERPARTCOEFF].cNeg, "no unit");
fnRead[OPT_WATERPARTCOEFF] = &ReadWaterPartCoeff;
/* Magma Ocean Depth */
sprintf(options[OPT_DEPTHMO].cName, "dDepthMO");
sprintf(options[OPT_DEPTHMO].cDescr, "Initial depth of the magma ocean");
sprintf(options[OPT_DEPTHMO].cDefault, "core radius");
sprintf(options[OPT_DEPTHMO].cDimension, "length");
options[OPT_DEPTHMO].iType = 2;
options[OPT_DEPTHMO].bMultiFile = 1;
options[OPT_DEPTHMO].dNeg = 1e3;
options[OPT_DEPTHMO].dDefault = 1e6;
sprintf(options[OPT_DEPTHMO].cNeg, "km");
fnRead[OPT_DEPTHMO] = &ReadDepthMO;
/* Halts */
sprintf(options[OPT_HALTMANTLESOLIDIFIED].cName, "bHaltMantleSolidified");
sprintf(options[OPT_HALTMANTLESOLIDIFIED].cDescr,
"Halt when mantle solidified?");
sprintf(options[OPT_HALTMANTLESOLIDIFIED].cDefault, "0");
options[OPT_HALTMANTLESOLIDIFIED].iType = 0;
fnRead[OPT_HALTMANTLESOLIDIFIED] = &ReadHaltMantleSolidified;
sprintf(options[OPT_HALTMANTLEMELTFRACLOW].cName, "bHaltMantleMeltFracLow");
sprintf(options[OPT_HALTMANTLEMELTFRACLOW].cDescr,
"Halt when mantle mostly solidified?");
sprintf(options[OPT_HALTMANTLEMELTFRACLOW].cDefault, "0");
options[OPT_HALTMANTLEMELTFRACLOW].iType = 0;
fnRead[OPT_HALTMANTLEMELTFRACLOW] = &ReadHaltMantleMeltFracLow;
sprintf(options[OPT_HALTATMDESISRUFCOOL].cName, "bHaltAtmDesiSurfCool");
sprintf(options[OPT_HALTATMDESISRUFCOOL].cDescr,
"Halt when atmosphere desiccated and surface below 1000K?");
sprintf(options[OPT_HALTATMDESISRUFCOOL].cDefault, "0");
options[OPT_HALTATMDESISRUFCOOL].iType = 0;
fnRead[OPT_HALTATMDESISRUFCOOL] = &ReadHaltAtmDesiSurfCool;
sprintf(options[OPT_HALTENTERHABZONE].cName, "bHaltEnterHabZone");
sprintf(options[OPT_HALTENTERHABZONE].cDescr,
"Halt when planet enters habitable zone?");
sprintf(options[OPT_HALTENTERHABZONE].cDefault, "0");
options[OPT_HALTENTERHABZONE].iType = 0;
fnRead[OPT_HALTENTERHABZONE] = &ReadHaltEnterHabZone;
sprintf(options[OPT_HALTALLPLANETSSOLID].cName, "bHaltAllPlanetsSolid");
sprintf(options[OPT_HALTALLPLANETSSOLID].cDescr,
"Halt when all planets solidified?");
sprintf(options[OPT_HALTALLPLANETSSOLID].cDefault, "0");
options[OPT_HALTALLPLANETSSOLID].iType = 0;
fnRead[OPT_HALTALLPLANETSSOLID] = &ReadHaltAllPlanetsSolid;
// XXX Overlap with bHaltSurfaceDesiccated in AtmEsc
sprintf(options[OPT_HALTALLPLANETSDESICC].cName, "bHaltAllPlanetsDesicc");
sprintf(options[OPT_HALTALLPLANETSDESICC].cDescr,
"Halt when all planets desiccated?");
sprintf(options[OPT_HALTALLPLANETSDESICC].cDefault, "0");
options[OPT_HALTALLPLANETSDESICC].iType = 0;
fnRead[OPT_HALTALLPLANETSDESICC] = &ReadHaltAllPlanetsDesicc;
/* Model options */
sprintf(options[OPT_RADIOHEATMODEL].cName, "sRadioHeatModel");
sprintf(options[OPT_RADIOHEATMODEL].cDescr, "Radiogenic heating model");
sprintf(options[OPT_RADIOHEATMODEL].cDefault, "NONE");
options[OPT_RADIOHEATMODEL].iType = 3;
options[OPT_RADIOHEATMODEL].bMultiFile = 1;
fnRead[OPT_RADIOHEATMODEL] = &ReadRadioHeatModel;
sprintf(options[OPT_MAGMOCATMMODEL].cName, "sMagmOcAtmModel");
sprintf(options[OPT_MAGMOCATMMODEL].cDescr,
"Atmospheric flux model: Grey or Petit");
sprintf(options[OPT_MAGMOCATMMODEL].cDefault, "GREY");
options[OPT_MAGMOCATMMODEL].iType = 3;
options[OPT_MAGMOCATMMODEL].bMultiFile = 1;
fnRead[OPT_MAGMOCATMMODEL] = &ReadMagmOcAtmModel;
sprintf(options[OPT_MANQUASISOL].cName, "bOptManQuasiSol");
sprintf(options[OPT_MANQUASISOL].cDescr, "Solidify when melt frac = 0.4?");
sprintf(options[OPT_MANQUASISOL].cDefault, "0");
options[OPT_MANQUASISOL].iType = 0;
options[OPT_MANQUASISOL].bMultiFile = 1;
fnRead[OPT_MANQUASISOL] = &ReadMantleQuasiSolid;
}
// Don't change this
void ReadOptionsMagmOc(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, fnReadOption fnRead[],
int iBody) {
int iOpt;
for (iOpt = OPTSTARTMAGMOC; iOpt < OPTENDMAGMOC; iOpt++) {
if (options[iOpt].iType != -1) {
fnRead[iOpt](body, control, files, &options[iOpt], system, iBody + 1);
}
}
}
// Initilaization of variables
void InitializeBodyMagmOc(BODY *body, CONTROL *control, UPDATE *update,
int iBody, int iModule) {
double dSolidRadiusLocalLow, dSolidRadiusLocalHigh;
// primary variables: HARD CODED INITIAL VALUES
body[iBody].dPotTemp =
body[iBody].dSurfTemp; // initial potential temp = initial surface temp
body[iBody].dCoreRadius = body[iBody].dRadius * RADCOREEARTH /
REARTH; // same relative core radius as Earth
body[iBody].dWaterMassMOAtm =
body[iBody].dWaterMassAtm; // initial water mass in MO&Atm is equal to
// inital Water mass in atmosphere
body[iBody].dWaterMassSol = 0; // initial water mass in solid = 0
body[iBody].dOxygenMassMOAtm = 0; // initial oxygen mass in MO&Atm = 0
body[iBody].dOxygenMassSol = 0; // initial oxygen mass in solid = 0
body[iBody].dGravAccelSurf =
BIGG * body[iBody].dMass / pow(body[iBody].dRadius, 2);
dSolidRadiusLocalLow =
body[iBody].dRadius -
((BLOWPRESSURE - body[iBody].dPotTemp) /
(body[iBody].dGravAccelSurf *
(body[iBody].dPotTemp * THERMALEXPANCOEFF / SILICATEHEATCAP -
ALOWPRESSURE * body[iBody].dManMeltDensity)));
dSolidRadiusLocalHigh =
body[iBody].dRadius -
((BHIGHPRESSURE - body[iBody].dPotTemp) /
(body[iBody].dGravAccelSurf *
(body[iBody].dPotTemp * THERMALEXPANCOEFF / SILICATEHEATCAP -
AHIGHPRESSURE * body[iBody].dManMeltDensity)));
body[iBody].dSolidRadius = fmin(dSolidRadiusLocalLow, dSolidRadiusLocalHigh);
if (body[iBody].dSolidRadius < body[iBody].dCoreRadius) {
body[iBody].dSolidRadius = body[iBody].dCoreRadius;
}
// if (body[iBody].dDepthMO < 9e8) {
// body[iBody].dSolidRadius = body[iBody].dRadius - body[iBody].dDepthMO;
// }
// other variables
double dTransPressSol =
5.19964e9; // pressure at which to swith from low to high pressure
// treatment of solidus (Hirschmann, 2000) in Pa
body[iBody].dPrefactorA = AHIGHPRESSURE;
body[iBody].dPrefactorB = BHIGHPRESSURE;
body[iBody].dAlbedo = ALBEDOWATERATMOS;
body[iBody].dFracFe2O3Man = 0;
body[iBody].dPressOxygenAtm = 0;
body[iBody].dTransDepthSol =
body[iBody].dRadius -
pow((pow(body[iBody].dRadius, 2) -
2 * body[iBody].dRadius * dTransPressSol /
(body[iBody].dManMeltDensity * body[iBody].dGravAccelSurf)),
0.5);
body[iBody].dHydrogenMassSpace = 0;
body[iBody].dOxygenMassSpace = 0;
// CO2
body[iBody].dPressCO2Atm = body[iBody].dCO2MassMOAtm *
body[iBody].dGravAccelSurf /
(4 * PI *
pow(body[iBody].dRadius,
2)); // initial CO2 mass in MO&Atm is equal to
// inital CO2 mass in atmosphere
body[iBody].dCO2MassSol = 0; // initial water mass in solid = 0
if (body[iBody].dCO2MassMOAtm < 1) {
body[iBody].bCO2InAtmosphere = 0;
} else {
body[iBody].bCO2InAtmosphere = 1;
}
body[iBody].dCO2FracMelt =
body[iBody].dCO2MassMOAtm /
(4 / 3 * PI * body[iBody].dManMeltDensity *
(pow(body[iBody].dRadius, 3) - pow(body[iBody].dCoreRadius, 3)));
// initialize water pressure in atmosphere to avoid deviding by 0. Use 1 % of
// initial water mass
body[iBody].dPressWaterAtm = body[iBody].dWaterMassAtm *
body[iBody].dGravAccelSurf /
(4 * PI * pow(body[iBody].dRadius, 2));
// initialize bools
body[iBody].bManSolid = 0; // start with a (partially) molten mantle
body[iBody].bAllFeOOxid = 0; // start with a unoxidized FeO
if (body[iBody].dPressWaterAtm >= PRESSWATERMIN) {
body[iBody].bPlanetDesiccated =
0; // start with water in the atm + mo system
} else {
body[iBody].bPlanetDesiccated = 1; // desiccated from start
}
body[iBody].bManStartSol = 0; // mantle does not solidify from beginning
body[iBody].bLowPressSol = 0; // start high pressure region of mantle
body[iBody].bManQuasiSol = 0; // start with a (partially) molten mantle
body[iBody].bEscapeStop = 0; // start with atmospheric escaped
body[iBody].bMagmOcHaltSolid = 0; // no halt at beginning
body[iBody].bMagmOcHaltDesicc = 0; // no halt at beginning
double dMassMantle;
double dManMolNum;
double dMolNumAl2O3, dMolNumCaO, dMolNumNa2O, dMolNumK2O, dMolNumFeO;
double dMolNumSiO2, dMolNumMgO, dMolNumTiO2, dMolNumP2O5;
dMassMantle =
4. / 3 * PI * body[iBody].dManMeltDensity *
(pow(body[iBody].dRadius, 3) - pow(body[iBody].dSolidRadius, 3));
dMolNumAl2O3 = dMassMantle * MASSFRACAL2O3 / MOLWEIGHTAL2O3;
dMolNumCaO = dMassMantle * MASSFRACCAO / MOLWEIGHTCAO;
dMolNumNa2O = dMassMantle * MASSFRACNA2O / MOLWEIGHTNA2O;
dMolNumK2O = dMassMantle * MASSFRACK2O / MOLWEIGHTK2O;
dMolNumFeO = dMassMantle * body[iBody].dMassFracFeOIni / MOLWEIGHTFEO;
dMolNumSiO2 = dMassMantle * MASSFRACSIO2 / MOLWEIGHTSIO2;
dMolNumMgO = dMassMantle * MASSFRACMGO / MOLWEIGHTMGO;
dMolNumTiO2 = dMassMantle * MASSFRACTIO2 / MOLWEIGHTTIO2;
dMolNumP2O5 = dMassMantle * MASSFRACP2O5 / MOLWEIGHTP2O5;
dManMolNum = dMolNumAl2O3 + dMolNumCaO + dMolNumNa2O + dMolNumK2O +
dMolNumFeO + dMolNumSiO2 + dMolNumMgO + dMolNumTiO2 +
dMolNumP2O5;
body[iBody].dAveMolarMassMan =
(MOLWEIGHTAL2O3 * dMolNumAl2O3 + MOLWEIGHTCAO * dMolNumCaO +
MOLWEIGHTNA2O * dMolNumNa2O + MOLWEIGHTK2O * dMolNumK2O +
MOLWEIGHTFEO * dMolNumFeO + MOLWEIGHTSIO2 * dMolNumSiO2 +
MOLWEIGHTMGO * dMolNumMgO + MOLWEIGHTTIO2 * dMolNumTiO2 +
MOLWEIGHTP2O5 * dMolNumP2O5) /
dManMolNum;
if (!body[0].bStellar) {
printf("Module STELLAR not used for star. Flux only for GJ1132. \n");
}
if (body[iBody].bCO2InAtmosphere &&
body[iBody].iMagmOcAtmModel == MAGMOC_PETIT) {
printf("WARNING: When including CO2, petit atmosphere model cannot be "
"used! Set to grey. \n");
body[iBody].iMagmOcAtmModel = MAGMOC_GREY;
}
if (body[iBody].iMagmOcAtmModel == MAGMOC_PETIT) {
printf("WARNING: petit atmosphere model can only be used when modelling "
"GJ1132b! \n");
}
}
/******************* Verify MAGMOC ******************/
/* Assign Nums */
/*
* Equations needed in PropsAuxMagmOc
*/
/**
Bisection method to find root
@param (*f) function pointer to the function the root of which should be found
@param body A pointer to the current BODY instance
@param dXl the lower boundary of the root finder
@param dXu the upper boundary of the root finder
@param iBody The current BODY number
@return dXm the root of function (*f)
*/
double fndBisection(double (*f)(BODY *, double, int), BODY *body, double dXl,
double dXu, double dEps, int iBody) {
double dXm, dEpsilon, dProd, dFxm, dFxl;
dEpsilon = 10 * dEps;
if (dEpsilon > dEps) {
while (dEpsilon > dEps) {
dXm = (dXl + dXu) / 2.;
dFxm = (*f)(body, dXm, iBody);
if (fabs(dFxm) < dEps) {
return dXm;
}
dFxl = (*f)(body, dXl, iBody);
if (fabs(dFxl) < dEps) {
return dXl;
}
dProd = (dFxl / fabs(dFxl)) * (dFxm / fabs(dFxm));
if (dProd < 0) {
dXu = dXm;
} else {
dXl = dXm;
}
dEpsilon = fabs((*f)(body, dXm, iBody));
}
return dXm;
} else {
fprintf(stderr,"ERROR: Tolerance factor <= 0 in fndBisection.");
exit(EXIT_INT);
}
}
/**
Mass of water in the mo+atm system to get the water frac in the magmoc
Will be used in PropsAuxMagmOc to find its root with fndBisection
@param body A pointer to the current BODY instance
@param dFrac water mass fraction in the magma oean
@param iBody The current BODY number
@return Water mass for a given dFrac - actual water mass in mo+atm
*/
double fndWaterMassMOTime(BODY *body, double dFrac, int iBody) {
return 1e-19 *
(body[iBody].dWaterPartCoeff * dFrac * body[iBody].dMassMagmOcCry +
dFrac * body[iBody].dMassMagmOcLiq +
(4 * PI * pow(body[iBody].dRadius, 2) / body[iBody].dGravAccelSurf) *
pow((dFrac / 3.44e-8), 1 / 0.74) -
body[iBody].dWaterMassMOAtm);
}
// return 1e-19 * ( WATERPARTCOEFF*dFrac*body[iBody].dMassMagmOcCry \
// + dFrac*body[iBody].dMassMagmOcLiq \
// + ( 4*PI*pow(body[iBody].dRadius,2) / body[iBody].dGravAccelSurf ) * pow((dFrac/3.44e-8),1/0.74) \
// - body[iBody].dWaterMassMOAtm );
// }
/**
Mass of CO2 in the mo+atm system to get the water frac in the magmoc
Will be used in PropsAuxMagmOc to find its root with fndBisection
@param body A pointer to the current BODY instance
@param dFracCO2 CO2 mass fraction in the magma oean
@param iBody The current BODY number
@return CO2 mass for a given dFracCO2 - actual CO2 mass in mo+atm
*/
double fndCO2MassMOTime(BODY *body, double dFracCO2, int iBody) {
double dPartialPressCO2AtmTemp;
double dPressCO2AtmTemp;
dPartialPressCO2AtmTemp = pow(((100 * dFracCO2 - 0.05) / 2.08e-4), 1 / 0.45);
dPressCO2AtmTemp =
1 / (2 * MOLWEIGHTCO2) *
((-1) * pow(pow(-MOLWEIGHTCO2 * dPartialPressCO2AtmTemp +
MOLWEIGHTWATER * body[iBody].dPressWaterAtm +
2 * MOLWEIGHTOXYGEN * body[iBody].dPressOxygenAtm,
2) +
4 * pow(MOLWEIGHTCO2, 2) * dPartialPressCO2AtmTemp *
(body[iBody].dPressOxygenAtm +
body[iBody].dPressWaterAtm),
0.5) +
dPartialPressCO2AtmTemp * MOLWEIGHTCO2 -
MOLWEIGHTWATER * body[iBody].dPressWaterAtm -
2 * MOLWEIGHTOXYGEN * body[iBody].dPressOxygenAtm);
return 1e-19 *
(CO2PARTCOEFF * dFracCO2 * body[iBody].dMassMagmOcCry +
dFracCO2 * body[iBody].dMassMagmOcLiq +
(4 * PI * pow(body[iBody].dRadius, 2) / body[iBody].dGravAccelSurf) *
dPressCO2AtmTemp -
body[iBody].dCO2MassMOAtm);
}
/**
Physical pressure of CO2 in the atmosphere
Will be used in PropsAuxMagmOc to find its root with fndBisection
@param body A pointer to the current BODY instance
@param dPhysPressCO2 Physical CO2 pressure in the atmosphere
@param iBody The current BODY number
@return 0
*/
double fndPhysPressCO2(BODY *body, double dPhysPressCO2, int iBody) {
double dAveMolarMassAtm;
dAveMolarMassAtm = (MOLWEIGHTWATER * body[iBody].dPressWaterAtm +
2 * MOLWEIGHTOXYGEN * body[iBody].dPressOxygenAtm +
MOLWEIGHTCO2 * dPhysPressCO2) /
(body[iBody].dPressWaterAtm + body[iBody].dPressOxygenAtm +
dPhysPressCO2);
return body[iBody].dPartialPressCO2Atm * MOLWEIGHTCO2 / dAveMolarMassAtm -
dPhysPressCO2;
}
/**
Radiogenic heating used in Schaefer et al. (2016)
Earth like composition
@param body A pointer to the current BODY instance
@param iBody The current BODY number
@return radiogenic heating rate
*/
double fndRadioHeatingEarth(BODY *body, int iBody) {
return 30.8e-9 * 9.46e-5 *
exp(1.55e-10 * (4.6e9 - body[iBody].dAge / YEARSEC)) +
0.22e-9 * 5.69e-4 *
exp(9.85e-10 * (4.6e9 - body[iBody].dAge / YEARSEC)) +
0124e-9 * 2.64e-5 *
exp(4.95e-11 * (4.6e9 - body[iBody].dAge / YEARSEC)) +
36.9e-9 * 2.92e-5 *
exp(5.55e-10 * (4.6e9 - body[iBody].dAge / YEARSEC));
}
/**
Bolometric flux of GJ1132 used in Schaefer et al. (2016)
Fit to Schaefer Fig. 2 (Baraffe, Mstar=0.18Msun, orbit of GJ1132b)
@param body A pointer to the current BODY instance
@param iBody The current BODY number
@return bolometric flux at GJ1132b's orbit
*/
double fndBolFluxSchaefer(BODY *body, int iBody) {
double dTimeGyr; // time in Gyr
dTimeGyr = 1e-9 * (body[iBody].dAge) / YEARSEC;
if (log10(dTimeGyr) < -0.782) {
return pow(10, (-0.73 * log10(dTimeGyr) + 3.81));
} else {
return pow(10, 4.38);
}
}
/**