1 |
ksteube |
1809 |
|
2 |
jfenwick |
3981 |
############################################################################## |
3 |
ksteube |
1312 |
# |
4 |
uqaeller |
6939 |
# Copyright (c) 2003-2020 by The University of Queensland |
5 |
jfenwick |
3981 |
# http://www.uq.edu.au |
6 |
ksteube |
1312 |
# |
7 |
ksteube |
1809 |
# Primary Business: Queensland, Australia |
8 |
jfenwick |
6112 |
# Licensed under the Apache License, version 2.0 |
9 |
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
10 |
ksteube |
1312 |
# |
11 |
jfenwick |
3981 |
# Development until 2012 by Earth Systems Science Computational Center (ESSCC) |
12 |
jfenwick |
4657 |
# Development 2012-2013 by School of Earth Sciences |
13 |
|
|
# Development from 2014 by Centre for Geoscience Computing (GeoComp) |
14 |
uqaeller |
6939 |
# Development from 2019 by School of Earth and Environmental Sciences |
15 |
jfenwick |
3981 |
# |
16 |
|
|
############################################################################## |
17 |
jgs |
127 |
|
18 |
sshaw |
5706 |
from __future__ import print_function, division |
19 |
|
|
|
20 |
uqaeller |
6939 |
__copyright__="""Copyright (c) 2003-2020 by The University of Queensland |
21 |
jfenwick |
3981 |
http://www.uq.edu.au |
22 |
ksteube |
1809 |
Primary Business: Queensland, Australia""" |
23 |
jfenwick |
6112 |
__license__="""Licensed under the Apache License, version 2.0 |
24 |
|
|
http://www.apache.org/licenses/LICENSE-2.0""" |
25 |
jfenwick |
2344 |
__url__="https://launchpad.net/escript-finley" |
26 |
elspeth |
628 |
|
27 |
jgs |
149 |
from esys.escript.modelframe import Model,ParameterSet |
28 |
|
|
from esys.escript.util import exp |
29 |
jfenwick |
2455 |
import numpy |
30 |
jgs |
127 |
|
31 |
jgs |
148 |
class GravityForce(ParameterSet): |
32 |
jgs |
149 |
""" |
33 |
|
|
Sets a gravity force of given direction in given domain: |
34 |
jgs |
127 |
|
35 |
jfenwick |
6647 |
:note: Instance variable domain - domain of interest (in). |
36 |
|
|
:note: Instance variable domain - `esys.escript.Domain` |
37 |
|
|
:note: Instance variable density - density, default 1 (in). |
38 |
|
|
:note: Instance variable gravity - the gravity constant, default 9.81 (in). |
39 |
|
|
:note: Instance variable direction - the direction of gravity, default [1.,0.,0.] (in). |
40 |
jgs |
147 |
""" |
41 |
gross |
918 |
def __init__(self,**kwargs): |
42 |
gross |
814 |
""" |
43 |
|
|
initializes the set |
44 |
|
|
""" |
45 |
gross |
918 |
super(GravityForce, self).__init__(**kwargs) |
46 |
jgs |
147 |
self.declareParameter(domain=None, |
47 |
|
|
gravity=9.81, \ |
48 |
|
|
density=1., \ |
49 |
|
|
direction=[1.,0.,0.]) |
50 |
|
|
|
51 |
|
|
def gravity_force(self): |
52 |
gross |
814 |
""" |
53 |
jfenwick |
2625 |
return the gravity force as `density` * `gravity` * `direction` |
54 |
gross |
814 |
""" |
55 |
|
|
if isinstance(self.direction,list): |
56 |
jfenwick |
2455 |
dir=numpy.array(self.direction[:self.domain.getDim()]) |
57 |
gross |
814 |
else: |
58 |
jgs |
147 |
dir=self.direction[:self.domain.getDim()] |
59 |
gross |
814 |
return self.gravity*self.density*dir |
60 |
jgs |
147 |
|
61 |
|
|
|
62 |
|
|
|
63 |
jgs |
148 |
class MaterialTable(ParameterSet): |
64 |
jgs |
149 |
""" |
65 |
|
|
A simple matrial table which allows setting physical ivar of a model |
66 |
jgs |
127 |
|
67 |
jfenwick |
2625 |
:ivar density: density(in/out) |
68 |
|
|
:ivar heat_capacity: heat_capacity(in/out) |
69 |
|
|
:ivar thermal_permabilty: permabilty(in/out) |
70 |
|
|
:ivar viscosity: viscosity(in/out) |
71 |
|
|
:ivar radiation_coefficient: (in/out) |
72 |
jgs |
127 |
""" |
73 |
gross |
918 |
def __init__(self,**kwargs): |
74 |
|
|
super(MaterialTable, self).__init__(**kwargs) |
75 |
jgs |
147 |
self.declareParameter(gravity=9.81, \ |
76 |
jgs |
127 |
density=1., \ |
77 |
jgs |
147 |
heat_capacity=1., \ |
78 |
jgs |
127 |
thermal_permabilty=1., \ |
79 |
|
|
radiation_coefficient=0.) |
80 |
|
|
|
81 |
jgs |
148 |
class SimpleEarthModel(ParameterSet): |
82 |
jgs |
149 |
""" |
83 |
jfenwick |
2061 |
A simple matrial table run convection models:: |
84 |
jgs |
147 |
|
85 |
gross |
814 |
density=density0*(1-expansion_coefficient*(temperature-reference_temperature)) |
86 |
jgs |
149 |
viscocity=viscocity0*(exp(alpha*(1/reference_temperature - 1/temperature)) |
87 |
jgs |
147 |
|
88 |
jfenwick |
2625 |
:ivar gravity: gravity constants (9.81) (in) |
89 |
|
|
:ivar reference_temperature: reference temperature (in) |
90 |
|
|
:ivar density0: density at reference temperature (in) |
91 |
|
|
:ivar viscosity0: viscosity0 at reference temperature (in) |
92 |
|
|
:ivar alpha: viscosity contrast (in) |
93 |
|
|
:ivar expansion_coefficient: Raleigh number (in) |
94 |
|
|
:ivar heat_capacity: heat capacity (in) |
95 |
|
|
:ivar thermal_permabilty: permabilty (in) |
96 |
|
|
:ivar temperature: temperature (in) |
97 |
|
|
:ivar viscosity: viscosity (out) |
98 |
|
|
:ivar density: density (out) |
99 |
jgs |
147 |
""" |
100 |
gross |
918 |
def __init__(self,**kwargs): |
101 |
|
|
super(SimpleEarthModel, self).__init__(**kwargs) |
102 |
jgs |
147 |
self.declareParameter(reference_temperature=1., |
103 |
|
|
gravity=9.81, \ |
104 |
|
|
density0=1., \ |
105 |
gross |
814 |
expansion_coefficient=0., \ |
106 |
jgs |
147 |
viscosity0=1., \ |
107 |
|
|
alpha=0., \ |
108 |
gross |
918 |
temperature=0.,\ |
109 |
jgs |
147 |
heat_capacity=1., \ |
110 |
|
|
thermal_permabilty=1.) |
111 |
|
|
|
112 |
|
|
def density(self): |
113 |
gross |
814 |
return self.density0*(1-self.expansion_coefficient*(self.temperature-self.reference_temperature)) |
114 |
jgs |
147 |
|
115 |
|
|
def viscosity(self): |
116 |
|
|
return self.viscosity0*exp(self.alpha*(1/self.reference_temperature - 1/(self.temperature+1.e-15))) |
117 |
|
|
|
118 |
jgs |
127 |
class SimpleSolidMaterial(MaterialTable): |
119 |
jgs |
149 |
""" |
120 |
|
|
A simple matrial table which allows setting physical parameters of |
121 |
|
|
a model. |
122 |
jgs |
127 |
""" |
123 |
gross |
918 |
def __init__(self,**kwargs): |
124 |
|
|
super(MaterialTable, self).__init__(**kwargs) |
125 |
jgs |
127 |
self.declareParameter(lame_lambda=1.,\ |
126 |
|
|
lame_my=1.) |
127 |
|
|
|
128 |
|
|
class SimpleFluidMaterial(MaterialTable): |
129 |
jgs |
149 |
""" |
130 |
|
|
A simple matrial table which allows setting physical ivar of a model. |
131 |
jgs |
127 |
""" |
132 |
gross |
918 |
def __init__(self,**kwargs): |
133 |
|
|
super(MaterialTable, self).__init__(**kwargs) |
134 |
jgs |
127 |
self.declareParameter(viscosity=1., \ |
135 |
|
|
hydraulic_conductivity=1.e-4) |
136 |
|
|
|
137 |
jgs |
149 |
# vim: expandtab shiftwidth=4: |