/[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 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (10 months, 1 week ago) by uqaeller
File MIME type: text/x-python
File size: 5487 byte(s)
Updated the copyright header.


1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2020 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Apache License, version 2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 # Development from 2019 by School of Earth and Environmental Sciences
15 #
16 ##############################################################################
17
18 from __future__ import print_function, division
19
20 __copyright__="""Copyright (c) 2003-2020 by The University of Queensland
21 http://www.uq.edu.au
22 Primary Business: Queensland, Australia"""
23 __license__="""Licensed under the Apache License, version 2.0
24 http://www.apache.org/licenses/LICENSE-2.0"""
25 __url__="https://launchpad.net/escript-finley"
26
27 from esys.escript.modelframe import Model,ParameterSet
28 from esys.escript.util import exp
29 import numpy
30
31 class GravityForce(ParameterSet):
32 """
33 Sets a gravity force of given direction in given domain:
34
35 :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 """
41 def __init__(self,**kwargs):
42 """
43 initializes the set
44 """
45 super(GravityForce, self).__init__(**kwargs)
46 self.declareParameter(domain=None,
47 gravity=9.81, \
48 density=1., \
49 direction=[1.,0.,0.])
50
51 def gravity_force(self):
52 """
53 return the gravity force as `density` * `gravity` * `direction`
54 """
55 if isinstance(self.direction,list):
56 dir=numpy.array(self.direction[:self.domain.getDim()])
57 else:
58 dir=self.direction[:self.domain.getDim()]
59 return self.gravity*self.density*dir
60
61
62
63 class MaterialTable(ParameterSet):
64 """
65 A simple matrial table which allows setting physical ivar of a model
66
67 :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 """
73 def __init__(self,**kwargs):
74 super(MaterialTable, self).__init__(**kwargs)
75 self.declareParameter(gravity=9.81, \
76 density=1., \
77 heat_capacity=1., \
78 thermal_permabilty=1., \
79 radiation_coefficient=0.)
80
81 class SimpleEarthModel(ParameterSet):
82 """
83 A simple matrial table run convection models::
84
85 density=density0*(1-expansion_coefficient*(temperature-reference_temperature))
86 viscocity=viscocity0*(exp(alpha*(1/reference_temperature - 1/temperature))
87
88 :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 """
100 def __init__(self,**kwargs):
101 super(SimpleEarthModel, self).__init__(**kwargs)
102 self.declareParameter(reference_temperature=1.,
103 gravity=9.81, \
104 density0=1., \
105 expansion_coefficient=0., \
106 viscosity0=1., \
107 alpha=0., \
108 temperature=0.,\
109 heat_capacity=1., \
110 thermal_permabilty=1.)
111
112 def density(self):
113 return self.density0*(1-self.expansion_coefficient*(self.temperature-self.reference_temperature))
114
115 def viscosity(self):
116 return self.viscosity0*exp(self.alpha*(1/self.reference_temperature - 1/(self.temperature+1.e-15)))
117
118 class SimpleSolidMaterial(MaterialTable):
119 """
120 A simple matrial table which allows setting physical parameters of
121 a model.
122 """
123 def __init__(self,**kwargs):
124 super(MaterialTable, self).__init__(**kwargs)
125 self.declareParameter(lame_lambda=1.,\
126 lame_my=1.)
127
128 class SimpleFluidMaterial(MaterialTable):
129 """
130 A simple matrial table which allows setting physical ivar of a model.
131 """
132 def __init__(self,**kwargs):
133 super(MaterialTable, self).__init__(**kwargs)
134 self.declareParameter(viscosity=1., \
135 hydraulic_conductivity=1.e-4)
136
137 # 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