/[escript]/branches/3.4.1/modellib/py_src/materials.py
ViewVC logotype

Contents of /branches/3.4.1/modellib/py_src/materials.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4587 - (show annotations)
Wed Dec 11 06:17:09 2013 UTC (5 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 5212 byte(s)
Preparation begins

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

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26