-
Notifications
You must be signed in to change notification settings - Fork 55
/
atmesc.c
4519 lines (4003 loc) · 170 KB
/
atmesc.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
/**
@file atmesc.c
@brief Subroutines that control the integration of the
atmospheric escape model.
@author Rodrigo Luger ([[email protected]](mailto:[email protected]>))
@date May 12 2015
@par Description
\rst
This module defines differential equations controlling the evolution
of planetary atmospheres under intense extreme ultraviolet (XUV)
stellar irradiation. The `atmesc <atmesc.html>`_ module implements
energy-limited and diffusion-limited escape for hydrogen/helium atmospheres
and water vapor atmospheres following :cite:`Luger2015`,
:cite:`LugerBarnes2015`, and :cite:`LehmerCatling17`. \endrst
*/
#include "vplanet.h"
/**
Create a copy of the body at index \p iBody. Used during integration
of the differential equations.
@param dest The body copy
@param src The original body instance
@param foo Who knows!?
@param iNumBodies Number of bodies
@param iBody Current body index
*/
void BodyCopyAtmEsc(BODY *dest, BODY *src, int foo, int iNumBodies, int iBody) {
dest[iBody].dSurfaceWaterMass = src[iBody].dSurfaceWaterMass;
dest[iBody].dOxygenMass = src[iBody].dOxygenMass;
dest[iBody].dOxygenMantleMass = src[iBody].dOxygenMantleMass;
dest[iBody].dEnvelopeMass = src[iBody].dEnvelopeMass;
dest[iBody].dXFrac = src[iBody].dXFrac;
dest[iBody].dAtmXAbsEffH = src[iBody].dAtmXAbsEffH;
dest[iBody].dAtmXAbsEffH2O = src[iBody].dAtmXAbsEffH2O;
dest[iBody].dMinSurfaceWaterMass = src[iBody].dMinSurfaceWaterMass;
dest[iBody].dMinEnvelopeMass = src[iBody].dMinEnvelopeMass;
dest[iBody].iWaterLossModel = src[iBody].iWaterLossModel;
dest[iBody].iAtmXAbsEffH2OModel = src[iBody].iAtmXAbsEffH2OModel;
dest[iBody].dKTide = src[iBody].dKTide;
dest[iBody].dMDotWater = src[iBody].dMDotWater;
dest[iBody].dFHRef = src[iBody].dFHRef;
dest[iBody].dOxygenEta = src[iBody].dOxygenEta;
dest[iBody].dCrossoverMass = src[iBody].dCrossoverMass;
dest[iBody].bRunaway = src[iBody].bRunaway;
dest[iBody].iWaterEscapeRegime = src[iBody].iWaterEscapeRegime;
dest[iBody].iHEscapeRegime = src[iBody].iHEscapeRegime;
dest[iBody].dFHDiffLim = src[iBody].dFHDiffLim;
dest[iBody].iPlanetRadiusModel = src[iBody].iPlanetRadiusModel;
dest[iBody].bInstantO2Sink = src[iBody].bInstantO2Sink;
dest[iBody].dRGDuration = src[iBody].dRGDuration;
dest[iBody].dRadXUV = src[iBody].dRadXUV;
dest[iBody].dRadSolid = src[iBody].dRadSolid;
dest[iBody].dPresXUV = src[iBody].dPresXUV;
dest[iBody].dPresSurf = src[iBody].dPresSurf;
dest[iBody].dScaleHeight = src[iBody].dScaleHeight;
dest[iBody].dThermTemp = src[iBody].dThermTemp;
dest[iBody].dFlowTemp = src[iBody].dFlowTemp;
dest[iBody].dAtmGasConst = src[iBody].dAtmGasConst;
dest[iBody].dFXUV = src[iBody].dFXUV;
dest[iBody].bCalcFXUV = src[iBody].bCalcFXUV;
dest[iBody].dJeansTime = src[iBody].dJeansTime;
dest[iBody].dRocheRadius = src[iBody].dRocheRadius;
dest[iBody].dMinKTide = src[iBody].dMinKTide;
dest[iBody].dAtmEscXi = src[iBody].dAtmEscXi;
dest[iBody].dBondiRadius = src[iBody].dBondiRadius;
dest[iBody].bUseEnergyLimited = src[iBody].bUseEnergyLimited;
dest[iBody].bUseRRLimited = src[iBody].bUseRRLimited;
dest[iBody].bUseBondiLimited = src[iBody].bUseBondiLimited;
dest[iBody].bAtmEscAuto = src[iBody].bAtmEscAuto;
dest[iBody].dEnvMassDt = src[iBody].dEnvMassDt;
dest[iBody].bAutoThermTemp = src[iBody].bAutoThermTemp;
dest[iBody].bStopWaterLossInHZ = src[iBody].bStopWaterLossInHZ;
}
/**************** ATMESC options ********************/
/**
Read the XUV flux from the input file.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadFXUV(BODY *body, CONTROL *control, FILES *files, OPTIONS *options,
SYSTEM *system, int iFile) {
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
body[iFile - 1].dFXUV =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dFXUV = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dFXUV = options->dDefault;
}
}
/**
\rst
Read the thermospheric temperature for the :cite:`LehmerCatling17` atmospheric
escape model. \endrst
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadThermTemp(BODY *body, CONTROL *control, FILES *files, OPTIONS *options,
SYSTEM *system, int iFile) {
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
body[iFile - 1].dThermTemp =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dThermTemp = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
body[iFile - 1].bAutoThermTemp = 0;
} else {
if (iFile > 0) {
/* Note that here we both assign the default and force the code to
calculate the thermal temperature automatically */
body[iFile - 1].bAutoThermTemp = 1;
body[iFile - 1].dThermTemp = options->dDefault;
}
}
}
/**
\rst
Read the temperature of the hydro flow for the Luger+Barnes escape model.
\endrst
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadFlowTemp(BODY *body, CONTROL *control, FILES *files, OPTIONS *options,
SYSTEM *system, int iFile) {
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
body[iFile - 1].dFlowTemp =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dFlowTemp = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dFlowTemp = options->dDefault;
}
}
/**
Read the atmospheric gas constant the Lehmer and Catling (2017) atmospheric
escape model.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadAtmGasConst(BODY *body, CONTROL *control, FILES *files,
OPTIONS *options, SYSTEM *system, int iFile) {
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
body[iFile - 1].dAtmGasConst =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dAtmGasConst = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dAtmGasConst = options->dDefault;
}
}
/**
Read the Jeans time, the time at which the flow transitions from hydrodynamic
to ballistic.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadJeansTime(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) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
body[iFile - 1].dJeansTime =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dJeansTime =
dTmp * fdUnitsTime(control->Units[iFile].iTime);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
if (control->Io.iVerbose >= VERBINPUT) {
fprintf(stderr,
"INFO: %s not set for body %s, defaulting to %.2e seconds.\n",
options->cName, body[iFile - 1].cName, options->dDefault);
}
body[iFile - 1].dJeansTime = options->dDefault;
}
}
}
/**
Read the effective XUV absorption pressure for the Lehmner and Catling (2017)
model.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadPresXUV(BODY *body, CONTROL *control, FILES *files, OPTIONS *options,
SYSTEM *system, int iFile) {
int lTmp = -1;
double dTmp;
AddOptionDouble(files->Infile[iFile].cIn, options->cName, &dTmp, &lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
body[iFile - 1].dPresXUV =
dTmp * dNegativeDouble(*options, files->Infile[iFile].cIn,
control->Io.iVerbose);
} else {
body[iFile - 1].dPresXUV = dTmp;
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dPresXUV = options->dDefault;
}
}
/**
Read the water loss model for the Luger and Barnes (2015) atmospheric escape
model.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadWaterLossModel(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), "lb15", 4)) {
body[iFile - 1].iWaterLossModel = ATMESC_LB15;
} else if (!memcmp(sLower(cTmp), "lbex", 4)) {
body[iFile - 1].iWaterLossModel = ATMESC_LBEXACT;
} else if (!memcmp(sLower(cTmp), "tian", 4)) {
body[iFile - 1].iWaterLossModel = ATMESC_TIAN;
} else if (!memcmp(sLower(cTmp), "ls16", 4)) {
body[iFile - 1].iWaterLossModel = ATMESC_LS2016;
} else {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr,
"ERROR: Unknown argument to %s: %s. Options are LB15, LBEXACT, "
"or TIAN.\n",
options->cName, cTmp);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].iWaterLossModel = ATMESC_LBEXACT;
}
}
/**
Read the XUV absorption efficiency model for the Luger and Barnes (2015)
atmospheric escape model.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadAtmXAbsEffH2OModel(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), "bolm", 4)) {
body[iFile - 1].iAtmXAbsEffH2OModel = ATMESC_BOL16;
} else if (!memcmp(sLower(cTmp), "none", 4)) {
body[iFile - 1].iAtmXAbsEffH2OModel = ATMESC_NONE;
} else {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr,
"ERROR: Unknown argument to %s: %s. Options are BOLMONT16 or "
"NONE.\n",
options->cName, cTmp);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].iAtmXAbsEffH2OModel = ATMESC_NONE;
}
}
/**
Read the planet radius model.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadPlanetRadiusModel(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), "lo", 2)) {
body[iFile - 1].iPlanetRadiusModel = ATMESC_LOP12;
} else if (!memcmp(sLower(cTmp), "le", 2)) {
body[iFile - 1].iPlanetRadiusModel = ATMESC_LEHMER17;
} else if (!memcmp(sLower(cTmp), "pr", 2)) {
body[iFile - 1].iPlanetRadiusModel = ATMESC_PROXCENB;
} else if (!memcmp(sLower(cTmp), "no", 2)) {
body[iFile - 1].iPlanetRadiusModel = ATMESC_NONE;
} else {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr,
"ERROR: Unknown argument to %s: %s. Options are LOPEZ12, "
"PROXCENB, LEHMER17 or NONE.\n",
options->cName, cTmp);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].iPlanetRadiusModel = ATMESC_NONE;
}
}
/**
Read the parameter that controls surface O2 sinks for the Luger and Barnes
(2015) model.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadInstantO2Sink(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].bInstantO2Sink = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
AssignDefaultInt(options, &body[iFile - 1].bInstantO2Sink,
files->iNumInputs);
}
}
/**
Read the parameter that controls water loss once planet reaches HZ.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadStopWaterLossInHZ(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].bStopWaterLossInHZ = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &body[iFile - 1].bStopWaterLossInHZ,
files->iNumInputs);
}
}
}
/**
Read the parameter that controls whether or not to limit envelope mass loss at
the Bondi limit
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadBondiLimited(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].bUseBondiLimited = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
AssignDefaultInt(options, &body[iFile - 1].bUseBondiLimited,
files->iNumInputs);
}
}
/**
Read the parameter that controls whether or not to use energy-limited escape
for H envelope mass loss
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadEnergyLimited(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].bUseEnergyLimited = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
AssignDefaultInt(options, &body[iFile - 1].bUseEnergyLimited,
files->iNumInputs);
}
}
/**
Read the parameter that controls whether or not to use
radiation/recombination-limited escape
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadRRLimited(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].bUseRRLimited = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
AssignDefaultInt(options, &body[iFile - 1].bUseRRLimited,
files->iNumInputs);
}
}
/**
Read the parameter that controls whether or not to let atmesc determine which
escape regime the planet is in
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadAtmEscAuto(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].bAtmEscAuto = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
AssignDefaultInt(options, &body[iFile - 1].bAtmEscAuto, files->iNumInputs);
}
}
/**
Read the planet's effective XUV radius.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadXFrac(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) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0 || dTmp > 1) {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr, "ERROR: %s must lie in the range [0,1].\n",
options->cName);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
body[iFile - 1].dXFrac = dTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dXFrac = options->dDefault;
}
}
/**
Read the XUV absorption efficiency for hydrogen.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadAtmXAbsEffH(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) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0 || dTmp > 1) {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr, "ERROR: %s must be in the range [0,1].\n",
options->cName);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
body[iFile - 1].dAtmXAbsEffH = dTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dAtmXAbsEffH = options->dDefault;
}
}
/**
Minimum value for KTide
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadMinKTide(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) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0 || dTmp > 1) {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr, "ERROR: %s must be in the range [0,1].\n",
options->cName);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
body[iFile - 1].dMinKTide = dTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dMinKTide = options->dDefault;
}
}
/**
Read the XUV absorption efficiency for water.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadAtmXAbsEffH2O(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) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0 || dTmp > 1) {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr, "ERROR: %s must be in the rane [0,1].\n",
options->cName);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
body[iFile - 1].dAtmXAbsEffH2O = dTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dAtmXAbsEffH2O = options->dDefault;
}
}
// ReadEnvelopeMass is in options.c to avoid memory leaks in verifying envelope.
/**
Read the planet's initial atmospheric oxygen mass (Luger and Barnes 2015 model).
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadOxygenMass(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) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr, "ERROR: %s must be >= 0.\n", options->cName);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
body[iFile - 1].dOxygenMass = dTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dOxygenMass = options->dDefault;
}
}
/**
Read the planet's initial mantle oxygen mass (Luger and Barnes 2015 model).
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadOxygenMantleMass(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) {
NotPrimaryInput(iFile, options->cName, files->Infile[iFile].cIn, lTmp,
control->Io.iVerbose);
if (dTmp < 0) {
if (control->Io.iVerbose >= VERBERR) {
fprintf(stderr, "ERROR: %s must be >= 0.\n", options->cName);
}
LineExit(files->Infile[iFile].cIn, lTmp);
}
body[iFile - 1].dOxygenMantleMass = dTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0) {
body[iFile - 1].dOxygenMantleMass = options->dDefault;
}
}
/* Halts */
/**
Read the parameter that controls whether the code halts when the planet is
desiccated.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadHaltMinSurfaceWaterMass(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].bSurfaceDesiccated = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &control->Halt[iFile - 1].bSurfaceDesiccated,
files->iNumInputs);
}
}
}
/* ReadMinSurfaceWaterMass is in options.c to avoid memory leaks when verifying
ocean. */
/* ReadSurfaceWaterMass is in options.c to avoid memory leaks when verifying
ocean. */
/**
Read the parameter that controls whether the code halts when the planet's
envelope is fully evaporated.
@param body A pointer to the current BODY instance
@param control A pointer to the integration CONTROL instance
@param files A pointer to the array of input FILES
@param options A pointer to the OPTIONS instance
@param system A pointer to the SYSTEM instance
@param iFile The current file number
*/
void ReadHaltMinEnvelopeMass(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].bEnvelopeGone = bTmp;
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else {
if (iFile > 0) {
AssignDefaultInt(options, &control->Halt[iFile - 1].bEnvelopeGone,
files->iNumInputs);
}
}
}
// ReadMinEnvelopeMass is in options.c to eliminate memory leak in verifying
// envelope
/**
Initialize the user options for the atmospheric escape model.
@param options A pointer to the OPTIONS instance
@param fnRead Array of pointers to the functions that read in the options
*/
void InitializeOptionsAtmEsc(OPTIONS *options, fnReadOption fnRead[]) {
fvFormattedString(&options[OPT_XFRAC].cName, "dXFrac");
fvFormattedString(&options[OPT_XFRAC].cDescr, "Fraction of planet radius in X-ray/UV");
fvFormattedString(&options[OPT_XFRAC].cDefault, "1");
fvFormattedString(&options[OPT_XFRAC].cDimension, "nd");
options[OPT_XFRAC].dDefault = 1.0;
options[OPT_XFRAC].iType = 2;
options[OPT_XFRAC].bMultiFile = 1;
fnRead[OPT_XFRAC] = &ReadXFrac;
fvFormattedString(
&options[OPT_XFRAC].cLongDescr,
"Ratio of the planet's XUV radius to its total radius. The XUV radius "
"is\n"
"defined to be the distance between the center of the planet and the\n"
"absorbing layer, defined to be where the optical depth is 1. Should "
"be\n"
"in the range (0,1].");
fvFormattedString(&options[OPT_ATMXABSEFFH].cName, "dAtmXAbsEffH");
fvFormattedString(&options[OPT_ATMXABSEFFH].cDescr,
"Hydrogen X-ray/UV absorption efficiency (epsilon)");
fvFormattedString(&options[OPT_ATMXABSEFFH].cDefault, "0.15");
fvFormattedString(&options[OPT_ATMXABSEFFH].cDimension, "nd");
options[OPT_ATMXABSEFFH].dDefault = 0.15;
options[OPT_ATMXABSEFFH].iType = 2;
options[OPT_ATMXABSEFFH].bMultiFile = 1;
fnRead[OPT_ATMXABSEFFH] = &ReadAtmXAbsEffH;
fvFormattedString(&options[OPT_ATMXABSEFFH].cLongDescr,
"XUV absoprtion efficiency parameter, epsilon_{XUV}, in Eq. (A1) in\n"
"Barnes et al. (2019). Must lie in the range [0,1].");
fvFormattedString(&options[OPT_ATMXABSEFFH2O].cName, "dAtmXAbsEffH2O");
fvFormattedString(&options[OPT_ATMXABSEFFH2O].cDescr,
"Water X-ray/UV absorption efficiency (epsilon)");
fvFormattedString(&options[OPT_ATMXABSEFFH2O].cDefault, "0.30");
fvFormattedString(&options[OPT_ATMXABSEFFH2O].cDimension, "nd");
options[OPT_ATMXABSEFFH2O].dDefault = 0.30;
options[OPT_ATMXABSEFFH2O].iType = 2;
options[OPT_ATMXABSEFFH2O].bMultiFile = 1;
fnRead[OPT_ATMXABSEFFH2O] = &ReadAtmXAbsEffH2O;
fvFormattedString(&options[OPT_ATMXABSEFFH2O].cLongDescr,
"XUV absoprtion efficiency parameter for water vapor as defined in\n"
"Luger & Barnes (2015, AsBio, 15, 57). Must lie in range [0,1].");
fvFormattedString(&options[OPT_ATMXABSEFFH2OMODEL].cName, "sAtmXAbsEffH2OModel");
fvFormattedString(&options[OPT_ATMXABSEFFH2OMODEL].cDescr,
"Water X-ray/XUV absorption efficiency evolution model");
fvFormattedString(&options[OPT_ATMXABSEFFH2OMODEL].cDefault, "NONE");
fvFormattedString(&options[OPT_ATMXABSEFFH2OMODEL].cValues, "BOLMONT16 NONE");
fvFormattedString(&options[OPT_ATMXABSEFFH2OMODEL].cDimension, "nd");
options[OPT_ATMXABSEFFH2OMODEL].iType = 3;
options[OPT_ATMXABSEFFH2OMODEL].bMultiFile = 1;
fnRead[OPT_ATMXABSEFFH2OMODEL] = &ReadAtmXAbsEffH2OModel;
fvFormattedString(&options[OPT_ATMXABSEFFH2OMODEL].cLongDescr,
"If BOLMONT16 is selected, then the value of %s will follow the "
"model of\n"
"Bolmont et al. (2017, MNRAS, 464, 3728). NONE will not change the "
"input\n"
"value for %s.",
options[OPT_ATMXABSEFFH2O].cName, options[OPT_ATMXABSEFFH2O].cName);
fvFormattedString(&options[OPT_OXYGENMASS].cName, "dOxygenMass");
fvFormattedString(&options[OPT_OXYGENMASS].cDescr,
"The initial oxygen mass in the atmosphere.");
fvFormattedString(&options[OPT_OXYGENMASS].cDefault, "0");
fvFormattedString(&options[OPT_OXYGENMASS].cDimension, "mass");
options[OPT_OXYGENMASS].dDefault = 0;
options[OPT_OXYGENMASS].iType = 2;
options[OPT_OXYGENMASS].bMultiFile = 1;
fnRead[OPT_OXYGENMASS] = &ReadOxygenMass;
// No LongDescr needed
fvFormattedString(&options[OPT_OXYGENMANTLEMASS].cName, "dOxygenMantleMass");
fvFormattedString(&options[OPT_OXYGENMANTLEMASS].cDescr,
"Initial Oxygen Mass in the Mantle");
fvFormattedString(&options[OPT_OXYGENMANTLEMASS].cDefault, "0");
fvFormattedString(&options[OPT_OXYGENMANTLEMASS].cDimension, "mass");
options[OPT_OXYGENMANTLEMASS].dDefault = 0;
options[OPT_OXYGENMANTLEMASS].iType = 2;
options[OPT_OXYGENMANTLEMASS].bMultiFile = 1;
fnRead[OPT_OXYGENMANTLEMASS] = &ReadOxygenMantleMass;
// No LongDescr needed
fvFormattedString(&options[OPT_WATERLOSSMODEL].cName, "sWaterLossModel");
fvFormattedString(&options[OPT_WATERLOSSMODEL].cDescr,
"Water loss and oxygen buildup model");
fvFormattedString(&options[OPT_WATERLOSSMODEL].cDefault, "LBEXACT");
fvFormattedString(&options[OPT_WATERLOSSMODEL].cValues, "LB15 LBEXACT TIAN LS16");
fvFormattedString(&options[OPT_WATERLOSSMODEL].cDimension, "nd");
options[OPT_WATERLOSSMODEL].iType = 3;
options[OPT_WATERLOSSMODEL].bMultiFile = 1;
fnRead[OPT_WATERLOSSMODEL] = &ReadWaterLossModel;
fvFormattedString(&options[OPT_WATERLOSSMODEL].cLongDescr,
"The water loss rate will be determined by the selected model.\n"
"The options are LB15, LBEXACT, TIAN, and LS16.\n");