forked from geodynamics/ellipsis3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grain_growth.c
196 lines (147 loc) · 6.38 KB
/
Grain_growth.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
/*
Copyright (C) 1995 The GeoFramework Consortium
This file is part of Ellipsis3D.
Ellipsis3D is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2,
as published by the Free Software Foundation.
Ellipsis3D is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Author:
Louis Moresi <[email protected]>
*/
#include "config.h"
#include <math.h>
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include "element_definitions.h"
#include "global_defs.h"
#include "function_prototypes.h"
/* Functions to compute grain growth to use in rheological law.
Applies if viscosity.GRAINSIZE != 0
Setup routines called from viscosity routines.
*/
void grain_growth_initialize(
struct All_variables *E
)
{
int i,j,el,level,rheo,material;
char default_str[40];
/* Which formulation is to be used .... growth/nucleation or empirical */
input_int("Grain_size_model",&(E->tracer.grain_size_model),"1");
for(material=0;material<=E->tracer.NUM_MATERIALS;material++) {
if(E->tracer.grain_size_model==1) {
sprintf(default_str,"Material_%d_grsz_epsT",material);
input_std_precision(default_str,&(E->tracer.grain[material].grsz_epsT),"0.0");
sprintf(default_str,"Material_%d_grsz_B",material);
input_std_precision(default_str,&(E->tracer.grain[material].grsz_B),"1.0");
sprintf(default_str,"Material_%d_grsz_stsexp",material);
input_std_precision(default_str,&(E->tracer.grain[material].grsz_stsexp),"1.0");
}
else if (E->tracer.grain_size_model==2) {
sprintf(default_str,"Material_%d_reduction_factor_e",material);
input_std_precision(default_str,&(E->tracer.grain[material].reduction_factor_equil),"1.0");
sprintf(default_str,"Material_%d_reduction_factor_m",material);
input_std_precision(default_str,&(E->tracer.grain[material].reduction_factor_metas),"1.0");
sprintf(default_str,"Material_%d_grain_T_dep",material);
input_int_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].GRAIN_T_dep,1);
sprintf(default_str,"Material_%d_grain_gr_a",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_a,0.0);
sprintf(default_str,"Material_%d_grain_gr_m",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_m,0.0);
sprintf(default_str,"Material_%d_grain_gr_Q",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_Q,0.0);
sprintf(default_str,"Material_%d_grain_gr_T",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_T,0.0);
sprintf(default_str,"Material_%d_grain_gr_T0",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_T0,0.0);
sprintf(default_str,"Material_%d_grain_nu_a",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].gnuc_a,0.0);
sprintf(default_str,"Material_%d_grain_nu_m",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].gnuc_m,0.0);
sprintf(default_str,"Material_%d_grain_nu_meps",material);
input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].gnuc_meps,0.0);
}
}
return;
}
void grow_grains(
struct All_variables *E
)
{
int m,material,phase;
standard_precision exp_term;
standard_precision delta_grain_size;
standard_precision grain_size_half;
standard_precision d_inf;
for(m=1;m<=E->tracer.NUM_TRACERS;m++) {
if(E->tracer.property_group[m] < 0)
continue;
material = E->tracer.property_group[m];
phase = E->tracer.Current_phase[m];
/* Exponential component of grain growth may be
linearized to match equivalent term in viscosity
law */
if(E->tracer.grain_size_model == 1) {
if(E->tracer.grain[material].grsz_epsT <= 0.0) /* fast way to switch off this effect */
continue;
d_inf = E->tracer.grain[material].grsz_B *
pow(E->tracer.strd[m], -E->tracer.grain[material].grsz_stsexp);
/* fprintf(stderr,"%d: d_inf = %g (stress = %g) \n",m, d_inf, E->tracer.strd[m] ); */
delta_grain_size = E->advection.timestep *
E->tracer.edot[m] / E->tracer.grain[material].grsz_epsT * (d_inf - E->tracer.grain_size[m]);
}
else if (E->tracer.grain_size_model == 2) {
/* 2nd Order method ... */
switch (E->tracer.grain[material].GRAIN_T_dep[phase]) {
case 1: /* Linearized exponential */
exp_term = exp(E->tracer.grain[material].ggrw_T[phase] * E->tracer.T[m]);
break;
case 2:
exp_term = exp(-E->tracer.grain[material].ggrw_Q[phase]/
(E->tracer.grain[material].ggrw_T[phase] *
(E->tracer.T[m] + E->tracer.grain[material].ggrw_T0[phase])));
break;
default:
fprintf(stderr,"Grain growth exponential term undefined\n");
exit(-1);
}
delta_grain_size = E->advection.timestep *
( /* growth terms */
E->tracer.grain[material].ggrw_a[phase] *
pow(E->tracer.grain_size[m],E->tracer.grain[material].ggrw_m[phase]) *
exp_term -
/* reduction terms */
E->tracer.grain[material].gnuc_a[phase] *
pow(E->tracer.grain_size[m],E->tracer.grain[material].gnuc_m[phase]) *
pow(E->tracer.edot[m],E->tracer.grain[material].gnuc_meps[phase])
);
}
else
delta_grain_size = 0.0;
E->tracer.grain_size[m] += delta_grain_size;
}
return;
}
void phase_boundary_grain_size(
struct All_variables *E,
int tr,
int meta
)
{
int material;
/* in simplified form, only change grain
size for transformation from metastable state */
material = E->tracer.property_group[tr];
/* E->tracer.grain_size[1] = 0.1; */
/* 1. Check to see if a phase change has recently occurred */
if(E->tracer.time_since_phase_change[tr] == 0.0) {
if(meta)
E->tracer.grain_size[tr] = E->tracer.grain[material].reduction_factor_metas; /* *= */
else
E->tracer.grain_size[tr] = E->tracer.grain[material].reduction_factor_equil; /* *= */
}
return;
}