/[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 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (22 months ago) by jfenwick
File MIME type: text/x-python
File size: 5417 byte(s)
Make everyone sad by touching all the files

Copyright dates update

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