-
Notifications
You must be signed in to change notification settings - Fork 2
/
RiftingChenin.c
executable file
·136 lines (124 loc) · 5.05 KB
/
RiftingChenin.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
#include "math.h"
#include "mdoodz.h"
#include "stdbool.h"
#include "stdlib.h"
#include "stdio.h"
double SetSurfaceZCoord(MdoodzInput *instance, double x_coord) {
const double TopoLevel = -0.0e3 / instance->scaling.L;
const double h_pert = instance->model.user3 / instance->scaling.L;
return TopoLevel + h_pert * (3330.0 - 2800.0) / 2800.0 * cos(2 * M_PI * x_coord / (instance->model.xmax - instance->model.xmin));
}
int SetPhase(MdoodzInput *instance, Coordinates coordinates) {
const double lithosphereThickness = instance->model.user1 / instance->scaling.L;
const double crustThickness = instance->model.user2 / instance->scaling.L;
const double perturbationAmplitude = instance->model.user3 / instance->scaling.L;
const double mohoLevel = -crustThickness - perturbationAmplitude * cos(2 * M_PI * coordinates.x / (instance->model.xmax - instance->model.xmin));
const bool isBelowLithosphere = coordinates.z < -lithosphereThickness;
const bool isAboveMoho = coordinates.z > mohoLevel;
if (instance->model.user4 && isAboveMoho) {
const bool is2500MAboveMoho = coordinates.z > mohoLevel + 2500 / instance->scaling.L;
const bool is4500MAboveMoho = coordinates.z > mohoLevel + 4500 / instance->scaling.L;
const bool is7000MAboveMoho = coordinates.z > mohoLevel + 7000 / instance->scaling.L;
const bool is9000MAboveMoho = coordinates.z > mohoLevel + 9000 / instance->scaling.L;
if (is2500MAboveMoho && !is4500MAboveMoho) {
return 7;
} else if (is7000MAboveMoho && !is9000MAboveMoho) {
return 8;
} else {
return 1;
}
} else if (isAboveMoho) {
return 1;
} else if (isBelowLithosphere) {
return 3;
} else {
return 2;
}
}
double SetTemperature(MdoodzInput *instance, Coordinates coordinates) {
const double lithosphereThickness = instance->model.user1 / instance->scaling.L;
const double surfaceTemperature = 273.15 / instance->scaling.T;
const double mantleTemperature = (1330.0 + 273.15) / instance->scaling.T;
const double particleTemperature = ((mantleTemperature - surfaceTemperature) / lithosphereThickness) * (-coordinates.z) + surfaceTemperature;
if (particleTemperature > mantleTemperature) {
return mantleTemperature;
} else {
return particleTemperature;
}
}
double SetGrainSize(MdoodzInput *instance, Coordinates coordinates, int phase) {
const int asthenospherePhase = 3;
return instance->materials.gs_ref[asthenospherePhase];
}
double SetHorizontalVelocity(MdoodzInput *instance, Coordinates coordinates) {
return -coordinates.x * instance->model.bkg_strain_rate;
}
double SetVerticalVelocity(MdoodzInput *instance, Coordinates coordinates) {
return coordinates.z * instance->model.bkg_strain_rate;
}
char SetBCPType(MdoodzInput *instance, POSITION position) {
if (position == NE || position == NW) {
return 0;
} else {
return -1;
}
}
SetBC SetBCT(MdoodzInput *instance, POSITION position, Coordinates coordinates, double particleTemperature) {
SetBC bc;
double surface_temperature = zeroC / instance->scaling.T;
double mantle_temperature = (1330. + zeroC) / instance->scaling.T;
if (position == S) {
bc.type = constant_temperature;
bc.value = mantle_temperature;
}
if (position == free_surface || position == N) {
bc.type = constant_temperature;
bc.value = surface_temperature;
}
if (position == W || position == E) {
bc.type = constant_heatflux;
bc.value = 0.;
}
return bc;
}
void AddCrazyConductivity(MdoodzInput *input) {
int *asthenospherePhases = (int *) malloc(sizeof(int));
CrazyConductivity *crazyConductivity = (CrazyConductivity *) malloc(sizeof(CrazyConductivity));
asthenospherePhases[0] = 3;
crazyConductivity->phases = asthenospherePhases;
crazyConductivity->nPhases = 1;
crazyConductivity->multiplier = 1000;
input->crazyConductivity = crazyConductivity;
}
int main(int nargs, char *args[]) {
// Input file name
char *input_file;
if ( nargs < 2 ) {
asprintf(&input_file, "RiftingChenin.txt"); // Default
}
else {
asprintf(&input_file, "%s", args[1]); // Custom
}
printf("Running MDoodz7.0 using %s\n", input_file);
MdoodzSetup setup = {
.BuildInitialTopography = &(BuildInitialTopography_ff){
.SetSurfaceZCoord = SetSurfaceZCoord,
},
.SetParticles = &(SetParticles_ff){
.SetPhase = SetPhase,
.SetTemperature = SetTemperature,
.SetGrainSize = SetGrainSize,
.SetHorizontalVelocity = SetHorizontalVelocity,
.SetVerticalVelocity = SetVerticalVelocity,
},
.SetBCs = &(SetBCs_ff){
.SetBCVx = SetPureShearBCVx,
.SetBCVz = SetPureShearBCVz,
.SetBCPType = SetBCPType,
.SetBCT = SetBCT,
},
.MutateInput = AddCrazyConductivity,
};
RunMDOODZ(input_file, &setup);
free(input_file);
}