/[escript]/trunk/modellib/py_src/materials.py
ViewVC logotype

Contents of /trunk/modellib/py_src/materials.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (10 years, 2 months ago) by jfenwick
File MIME type: text/x-python
File size: 5150 byte(s)
Don't panic.
Updating copyright stamps

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