forked from VirtualPlanetaryLaboratory/vplanet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.c
2097 lines (1813 loc) · 111 KB
/
update.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 update.c
@brief Subroutines controlling the integration
@author Rory Barnes ([RoryBarnes](https://github.com/RoryBarnes/))
@date A long, long time ago
*/
#include "vplanet.h"
void InitializeUpdateBodyPerts(CONTROL *control,UPDATE *update,int iBody) {
int iVar,iEqn;
for (iVar=0;iVar<update[iBody].iNumVars;iVar++) {
for (iEqn=0;iEqn<update[iBody].iNumEqns[iVar];iEqn++) {
control->Evolve.tmpUpdate[iBody].iaBody[iVar][iEqn] = malloc(update[iBody].iNumBodies[iVar][iEqn]*sizeof(int));
}
}
}
void InitializeUpdateTmpBody(BODY *body,CONTROL *control,MODULE *module,UPDATE *update,int iBody) {
int iModule;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnInitializeUpdateTmpBody[iBody][iModule](body,control,update,iBody);
}
void UpdateCopy(UPDATE *dest,UPDATE *src,int iNumBodies) {
int iBody,iVar,iEqn,iPert;
for (iBody=0;iBody<iNumBodies;iBody++) {
// The iNumX and iX members don't need to be copied
dest[iBody].iNumVars = src[iBody].iNumVars;
dest[iBody].iXobl = src[iBody].iXobl;
dest[iBody].iYobl = src[iBody].iYobl;
dest[iBody].iZobl = src[iBody].iZobl;
dest[iBody].iHecc = src[iBody].iHecc;
dest[iBody].iKecc = src[iBody].iKecc;
dest[iBody].iPinc = src[iBody].iPinc;
dest[iBody].iQinc = src[iBody].iQinc;
for (iVar=0;iVar<src[iBody].iNumVars;iVar++) {
dest[iBody].iNumEqns[iVar] = src[iBody].iNumEqns[iVar];
dest[iBody].iaVar[iVar] = src[iBody].iaVar[iVar];
for (iEqn=0;iEqn<src[iBody].iNumEqns[iVar];iEqn++) {
dest[iBody].iNumBodies[iVar][iEqn] = src[iBody].iNumBodies[iVar][iEqn];
dest[iBody].iaType[iVar][iEqn] = src[iBody].iaType[iVar][iEqn];
dest[iBody].iaModule[iVar][iEqn] = src[iBody].iaModule[iVar][iEqn];
for (iPert=0;iPert<src[iBody].iNumBodies[iVar][iEqn];iPert++)
dest[iBody].iaBody[iVar][iEqn][iPert] = src[iBody].iaBody[iVar][iEqn][iPert];
}
}
}
}
void InitializeUpdate(BODY*body,CONTROL *control,MODULE *module,UPDATE *update,fnUpdateVariable ****fnUpdate) {
int iBody,iBodyPert,iVar,iEqn,iModule,iLat,iFoo;
int iNum,iSubStep;
// Allocate the firt dimension of the Update matrix to be the number of bodies
*fnUpdate=malloc(control->Evolve.iNumBodies*sizeof(fnUpdateVariable**));
// For each body, determine how many independent variables need updating.
for (iBody=0;iBody<control->Evolve.iNumBodies;iBody++) {
// Assign dZero for any derivative pointers that need to point to 0
update[iBody].dZero = 0;
// Assume no modules to start
//update[iBody].iNumEcc=0;
update[iBody].iNum26AlMan=0;
update[iBody].iNum26AlCore=0;
update[iBody].iNum40KMan=0;
update[iBody].iNum40KCore=0;
update[iBody].iNum40KCrust=0;
update[iBody].iNum232ThMan=0;
update[iBody].iNum232ThCore=0;
update[iBody].iNum232ThCrust=0;
update[iBody].iNum235UMan=0;
update[iBody].iNum235UCore=0;
update[iBody].iNum235UCrust=0;
update[iBody].iNum238UMan=0;
update[iBody].iNum238UCore=0;
update[iBody].iNum238UCrust=0;
update[iBody].iNumCBPR=0;
update[iBody].iNumCBPZ=0;
update[iBody].iNumCBPPhi=0;
update[iBody].iNumCBPRDot=0;
update[iBody].iNumCBPZDot=0;
update[iBody].iNumCBPPhiDot=0;
update[iBody].iNumDynEllip=0;
update[iBody].iNumEnvelopeMass=0;
update[iBody].iNumHecc=0;
update[iBody].iNumKecc=0;
update[iBody].iNumLuminosity=0;
update[iBody].iNumLXUV=0;
update[iBody].iNumMass=0;
update[iBody].iNumPinc=0;
update[iBody].iNumQinc=0;
update[iBody].iNumRadGyra=0;
update[iBody].iNumRadius=0;
update[iBody].iNumRot=0;
update[iBody].iNumSemi=0;
update[iBody].iNumSurfaceWaterMass=0;
update[iBody].iNumOxygenMass=0;
update[iBody].iNumOxygenMantleMass=0;
update[iBody].iNumTemperature=0;
update[iBody].iNumTMan=0;
update[iBody].iNumTCore=0;
update[iBody].iNumXobl=0;
update[iBody].iNumYobl=0;
update[iBody].iNumZobl=0;
update[iBody].iNumEccX=0;
update[iBody].iNumEccY=0;
update[iBody].iNumEccZ = 0;
update[iBody].iNumAngMX =0;
update[iBody].iNumAngMY =0;
update[iBody].iNumAngMZ =0;
update[iBody].iNumPositionX = 0;
update[iBody].iNumPositionY = 0;
update[iBody].iNumPositionZ = 0;
update[iBody].iNumVelX = 0;
update[iBody].iNumVelY = 0;
update[iBody].iNumVelZ = 0;
update[iBody].iNumWaterMassMOAtm = 0;
update[iBody].iNumWaterMassSol = 0;
update[iBody].iNumSurfTemp = 0;
update[iBody].iNumPotTemp = 0;
update[iBody].iNumSolidRadius = 0;
update[iBody].iNumLostAngMom=0;
update[iBody].iNumLostEng=0;
update[iBody].iNumVars=0;
/* First we must identify how many variables and models must be
assigned so we can malloc the update struct. */
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnInitializeUpdate[iBody][iModule](body,update,iBody);
// Initialize multi-module equations
InitializeUpdateMulti(body,control,module,update,fnUpdate,iBody);
// The second dimension of the Update matrix is the variables
(*fnUpdate)[iBody]=malloc(update[iBody].iNumVars*sizeof(fnUpdateVariable*));
update[iBody].iaVar = malloc(update[iBody].iNumVars*sizeof(int));
update[iBody].iNumEqns = malloc(update[iBody].iNumVars*sizeof(int));
update[iBody].iaType = malloc(update[iBody].iNumVars*sizeof(int*));
update[iBody].iaModule = malloc(update[iBody].iNumVars*sizeof(int*));
update[iBody].pdVar = malloc(update[iBody].iNumVars*sizeof(double*));
update[iBody].daDeriv = malloc(update[iBody].iNumVars*sizeof(double));
update[iBody].daDerivProc = malloc(update[iBody].iNumVars*sizeof(double*));
update[iBody].iNumBodies = malloc(update[iBody].iNumVars*sizeof(int*));
update[iBody].iaBody = malloc(update[iBody].iNumVars*sizeof(int**));
// May also have to allocate space for the temp UPDATE
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].iaVar = malloc(update[iBody].iNumVars*sizeof(int));
control->Evolve.tmpUpdate[iBody].iNumEqns = malloc(update[iBody].iNumVars*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType = malloc(update[iBody].iNumVars*sizeof(int*));
control->Evolve.tmpUpdate[iBody].iaModule = malloc(update[iBody].iNumVars*sizeof(int*));
control->Evolve.tmpUpdate[iBody].pdVar = malloc(update[iBody].iNumVars*sizeof(double*));
control->Evolve.tmpUpdate[iBody].daDeriv = malloc(update[iBody].iNumVars*sizeof(double*));
control->Evolve.tmpUpdate[iBody].daDerivProc = malloc(update[iBody].iNumVars*sizeof(double*));
control->Evolve.tmpUpdate[iBody].iNumBodies = malloc(update[iBody].iNumVars*sizeof(int*));
control->Evolve.tmpUpdate[iBody].iaBody = malloc(update[iBody].iNumVars*sizeof(int**));
}
for (iSubStep=0;iSubStep<4;iSubStep++)
control->Evolve.daDeriv[iSubStep][iBody]=malloc(update[iBody].iNumVars*sizeof(double));
/* Now we malloc some pointers, and perform some initializations for the
UPDATE struct based on the primary variables required for each's
planet's assigned modules. */
iVar=0;
update[iBody].iVelX = -1;
if (update[iBody].iNumVelX) {
update[iBody].iVelX = iVar;
update[iBody].iaVar[iVar] = VVELX;
update[iBody].iNumEqns[iVar] = update[iBody].iNumVelX;
update[iBody].pdVar[iVar] = &body[iBody].dVelX;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumVelX*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumVelX*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumVelX*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumVelX*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dVelX;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumVelX*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumVelX*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumVelX*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumVelX*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumVelX*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateVelX[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iVelY = -1;
if (update[iBody].iNumVelY) {
update[iBody].iVelY = iVar;
update[iBody].iaVar[iVar] = VVELY;
update[iBody].iNumEqns[iVar] = update[iBody].iNumVelY;
update[iBody].pdVar[iVar] = &body[iBody].dVelY;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumVelY*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumVelY*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumVelY*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumVelY*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dVelY;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumVelY*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumVelY*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumVelY*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumVelY*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumVelY*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateVelY[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iVelZ = -1;
if (update[iBody].iNumVelZ) {
update[iBody].iVelZ = iVar;
update[iBody].iaVar[iVar] = VVELZ;
update[iBody].iNumEqns[iVar] = update[iBody].iNumVelZ;
update[iBody].pdVar[iVar] = &body[iBody].dVelZ;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dVelZ;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumVelZ*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumVelZ*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateVelZ[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iPositionX = -1;
if (update[iBody].iNumPositionX) {
update[iBody].iPositionX = iVar;
update[iBody].iaVar[iVar] = VPOSITIONX;
update[iBody].iNumEqns[iVar] = update[iBody].iNumPositionX;
update[iBody].pdVar[iVar] = &body[iBody].dPositionX;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dPositionX;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumPositionX*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumPositionX*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdatePositionX[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iPositionY = -1;
if (update[iBody].iNumPositionY) {
update[iBody].iPositionY = iVar;
update[iBody].iaVar[iVar] = VPOSITIONY;
update[iBody].iNumEqns[iVar] = update[iBody].iNumPositionY;
update[iBody].pdVar[iVar] = &body[iBody].dPositionY;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dPositionY;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumPositionY*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumPositionY*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdatePositionY[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iPositionZ = -1;
if (update[iBody].iNumPositionZ) {
update[iBody].iPositionZ = iVar;
update[iBody].iaVar[iVar] = VPOSITIONZ;
update[iBody].iNumEqns[iVar] = update[iBody].iNumPositionZ;
update[iBody].pdVar[iVar] = &body[iBody].dPositionZ;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dPositionZ;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumPositionZ*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdatePositionZ[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iWaterMassMOAtm = -1;
if (update[iBody].iNumWaterMassMOAtm) {
update[iBody].iWaterMassMOAtm = iVar;
update[iBody].iaVar[iVar] = VWATERMASSMOATM;
update[iBody].iNumEqns[iVar] = update[iBody].iNumWaterMassMOAtm;
update[iBody].pdVar[iVar] = &body[iBody].dWaterMassMOAtm;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dWaterMassMOAtm;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumWaterMassMOAtm*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateWaterMassMOAtm[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iWaterMassSol = -1;
if (update[iBody].iNumWaterMassSol) {
update[iBody].iWaterMassSol = iVar;
update[iBody].iaVar[iVar] = VWATERMASSSOL;
update[iBody].iNumEqns[iVar] = update[iBody].iNumWaterMassSol;
update[iBody].pdVar[iVar] = &body[iBody].dWaterMassSol;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dWaterMassSol;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumWaterMassSol*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateWaterMassSol[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iSurfTemp = -1;
if (update[iBody].iNumSurfTemp) {
update[iBody].iSurfTemp = iVar;
update[iBody].iaVar[iVar] = VSURFTEMP;
update[iBody].iNumEqns[iVar] = update[iBody].iNumSurfTemp;
update[iBody].pdVar[iVar] = &body[iBody].dSurfTemp;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dSurfTemp;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumSurfTemp*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateSurfTemp[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iPotTemp = -1;
if (update[iBody].iNumPotTemp) {
update[iBody].iPotTemp = iVar;
update[iBody].iaVar[iVar] = VPOTTEMP;
update[iBody].iNumEqns[iVar] = update[iBody].iNumPotTemp;
update[iBody].pdVar[iVar] = &body[iBody].dPotTemp;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dPotTemp;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumPotTemp*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdatePotTemp[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
update[iBody].iSolidRadius = -1;
if (update[iBody].iNumSolidRadius) {
update[iBody].iSolidRadius = iVar;
update[iBody].iaVar[iVar] = VSOLIDRADIUS;
update[iBody].iNumEqns[iVar] = update[iBody].iNumSolidRadius;
update[iBody].pdVar[iVar] = &body[iBody].dSolidRadius;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dSolidRadius;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumSolidRadius*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateSolidRadius[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 26Al Core */
update[iBody].i26AlCore = -1;
if (update[iBody].iNum26AlCore) {
update[iBody].i26AlCore = iVar;
update[iBody].iaVar[iVar] = VNUM26ALCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum26AlCore;
update[iBody].pdVar[iVar] = &body[iBody].d26AlNumCore;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d26AlNumCore;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum26AlCore*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate26AlNumCore[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 26Al Mantle */
update[iBody].i26AlMan = -1;
if (update[iBody].iNum26AlMan) {
update[iBody].i26AlMan = iVar;
update[iBody].iaVar[iVar] = VNUM26ALMAN;
update[iBody].iNumEqns[iVar] = update[iBody].iNum26AlMan;
update[iBody].pdVar[iVar] = &body[iBody].d26AlNumMan;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d26AlNumMan;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum26AlMan*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate26AlNumMan[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 40K Core */
update[iBody].i40KCore = -1;
if (update[iBody].iNum40KCore) {
update[iBody].i40KCore = iVar;
update[iBody].iaVar[iVar] = VNUM40KCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum40KCore;
update[iBody].pdVar[iVar] = &body[iBody].d40KNumCore;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d40KNumCore;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum40KCore*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum40KCore*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate40KNumCore[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 40K Mantle */
update[iBody].i40KMan = -1;
if (update[iBody].iNum40KMan) {
update[iBody].i40KMan = iVar;
update[iBody].iaVar[iVar] = VNUM40KMAN;
update[iBody].iNumEqns[iVar] = update[iBody].iNum40KMan;
update[iBody].pdVar[iVar] = &body[iBody].d40KNumMan;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d40KNumMan;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum40KMan*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum40KMan*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate40KNumMan[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 40K Crust */
update[iBody].i40KCrust = -1;
if (update[iBody].iNum40KCrust) {
update[iBody].i40KCrust = iVar;
update[iBody].iaVar[iVar] = VNUM40KCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum40KCrust;
update[iBody].pdVar[iVar] = &body[iBody].d40KNumCrust;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d40KNumCrust;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum40KCrust*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate40KNumCrust[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 232Th Core */
update[iBody].i232ThCore = -1;
if (update[iBody].iNum232ThCore) {
update[iBody].i232ThCore = iVar;
update[iBody].iaVar[iVar] = VNUM232THCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum232ThCore;
update[iBody].pdVar[iVar] = &body[iBody].d232ThNumCore;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d232ThNumCore;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum232ThCore*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate232ThNumCore[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 232Th Mantle */
update[iBody].i232ThMan = -1;
if (update[iBody].iNum232ThMan) {
update[iBody].i232ThMan = iVar;
update[iBody].iaVar[iVar] = VNUM232THMAN;
update[iBody].iNumEqns[iVar] = update[iBody].iNum232ThMan;
update[iBody].pdVar[iVar] = &body[iBody].d232ThNumMan;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d232ThNumMan;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum232ThMan*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate232ThNumMan[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 232Th Crust */
update[iBody].i232ThCrust = -1;
if (update[iBody].iNum232ThCrust) {
update[iBody].i232ThCrust = iVar;
update[iBody].iaVar[iVar] = VNUM232THCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum232ThCrust;
update[iBody].pdVar[iVar] = &body[iBody].d232ThNumCrust;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d232ThNumCrust;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum232ThCrust*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate232ThNumCrust[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 235U Core */
update[iBody].i235UCore = -1;
if (update[iBody].iNum235UCore) {
update[iBody].i235UCore = iVar;
update[iBody].iaVar[iVar] = VNUM235UCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum235UCore;
update[iBody].pdVar[iVar] = &body[iBody].d235UNumCore;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d235UNumCore;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum235UCore*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum235UCore*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate235UNumCore[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 235U Mantle */
update[iBody].i235UMan = -1;
if (update[iBody].iNum235UMan) {
update[iBody].i235UMan = iVar;
update[iBody].iaVar[iVar] = VNUM235UMAN;
update[iBody].iNumEqns[iVar] = update[iBody].iNum235UMan;
update[iBody].pdVar[iVar] = &body[iBody].d235UNumMan;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d235UNumMan;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum235UMan*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum235UMan*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate235UNumMan[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 235U Crust */
update[iBody].i235UCrust = -1;
if (update[iBody].iNum235UCrust) {
update[iBody].i235UCrust = iVar;
update[iBody].iaVar[iVar] = VNUM235UCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum235UCrust;
update[iBody].pdVar[iVar] = &body[iBody].d235UNumCrust;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d235UNumCrust;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum235UCrust*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate235UNumCrust[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 238U Core */
update[iBody].i238UCore = -1;
if (update[iBody].iNum238UCore) {
update[iBody].i238UCore = iVar;
update[iBody].iaVar[iVar] = VNUM238UCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum238UCore;
update[iBody].pdVar[iVar] = &body[iBody].d238UNumCore;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d238UNumCore;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum238UCore*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum238UCore*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate238UNumCore[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 238U Mantle */
update[iBody].i238UMan = -1;
if (update[iBody].iNum238UMan) {
update[iBody].i238UMan = iVar;
update[iBody].iaVar[iVar] = VNUM238UMAN;
update[iBody].iNumEqns[iVar] = update[iBody].iNum238UMan;
update[iBody].pdVar[iVar] = &body[iBody].d238UNumMan;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d238UNumMan;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum238UMan*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum238UMan*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate238UNumMan[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* 238U Crust */
update[iBody].i238UCrust = -1;
if (update[iBody].iNum238UCrust) {
update[iBody].i238UCrust = iVar;
update[iBody].iaVar[iVar] = VNUM238UCORE;
update[iBody].iNumEqns[iVar] = update[iBody].iNum238UCrust;
update[iBody].pdVar[iVar] = &body[iBody].d238UNumCrust;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].d238UNumCrust;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNum238UCrust*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdate238UNumCrust[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
// Atmospheric Envelope Mass
update[iBody].iEnvelopeMass = -1;
if (update[iBody].iNumEnvelopeMass) {
update[iBody].iEnvelopeMass = iVar;
update[iBody].iaVar[iVar] = VENVELOPEMASS;
update[iBody].iNumEqns[iVar] = update[iBody].iNumEnvelopeMass;
update[iBody].pdVar[iVar] = &body[iBody].dEnvelopeMass;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dEnvelopeMass;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumEnvelopeMass*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateEnvelopeMass[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
/* Dynamical ellipticity. There are 3 possibilities for dynamical
ellipticity: 1) It is a constant; 2) It is calculated from dViscUMan,
which is a constant and set by the option dViscUman (part of DISTROT);
3) It is calculated from dViscUMan, which is set by the mantle
temperature, i.e. THERMINT must be called. Only option #3 requires
DynEllip to be a primary variable. */
update[iBody].iDynEllip = -1;
if (update[iBody].iNumDynEllip) {
update[iBody].iDynEllip = iVar;
update[iBody].iaVar[iVar] = VDYNELLIP;
update[iBody].iNumEqns[iVar] = update[iBody].iNumDynEllip;
update[iBody].pdVar[iVar] = &body[iBody].dDynEllip;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dDynEllip;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumDynEllip*sizeof(int*));
}
iEqn=0;
for (iModule=0;iModule<module->iNumModules[iBody];iModule++)
module->fnFinalizeUpdateDynEllip[iBody][iModule](body,update,&iEqn,iVar,iBody,iFoo);
(*fnUpdate)[iBody][iVar]=malloc(iEqn*sizeof(fnUpdateVariable));
update[iBody].daDerivProc[iVar]=malloc(iEqn*sizeof(double));
iVar++;
}
// Poincare's h (Hecc)
update[iBody].iHecc = -1;
if (update[iBody].iNumHecc) {
update[iBody].iHecc = iVar;
update[iBody].iaVar[iVar] = VHECC;
update[iBody].iNumEqns[iVar] = update[iBody].iNumHecc;
update[iBody].pdVar[iVar] = &body[iBody].dHecc;
update[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumHecc*sizeof(int));
update[iBody].iaBody[iVar] = malloc(update[iBody].iNumHecc*sizeof(int*));
update[iBody].iaType[iVar] = malloc(update[iBody].iNumHecc*sizeof(int));
update[iBody].iaModule[iVar] = malloc(update[iBody].iNumHecc*sizeof(int));
if (control->Evolve.iOneStep == RUNGEKUTTA) {
control->Evolve.tmpUpdate[iBody].pdVar[iVar] = &control->Evolve.tmpBody[iBody].dHecc;
control->Evolve.tmpUpdate[iBody].iNumBodies[iVar] = malloc(update[iBody].iNumHecc*sizeof(int));
control->Evolve.tmpUpdate[iBody].daDerivProc[iVar] = malloc(update[iBody].iNumHecc*sizeof(double));
control->Evolve.tmpUpdate[iBody].iaType[iVar] = malloc(update[iBody].iNumHecc*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaModule[iVar] = malloc(update[iBody].iNumHecc*sizeof(int));
control->Evolve.tmpUpdate[iBody].iaBody[iVar] = malloc(update[iBody].iNumHecc*sizeof(int*));