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

Annotation of /trunk/modellib/py_src/input.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 127 - (hide annotations)
Fri Jul 22 05:11:29 2005 UTC (17 years, 8 months ago) by jgs
Original Path: trunk/esys2/modellib/py_src/input.py
File MIME type: text/x-python
File size: 1849 byte(s)
moved modellib code to esys2/modellib/py_src

1 jgs 127 # $Id$
2    
3    
4     from esys.modelframe import Model
5     from esys.escript import *
6     from math import log
7    
8    
9     class GausseanProfile(Model):
10     """@brief generates a gaussean profile at center x_c, width width and height A over a domain
11    
12     @param domain (in) - domain
13     @param x_c (in) - center of the Gaussean profile (default [0.,0.,0.])
14     @param A (in) - height of the profile. A maybe a vector. (default 1.)
15     @param width (in) - width of the profile (default 0.1)
16     @param r (in) - radius of the circle (default = 0)
17     @param out (out) - profile
18    
19    
20     In the case that the spatial dimension is two, The third component of x_c is dropped
21     """
22     def __init__(self,debug=False):
23     Model.__init__(self,debug=debug)
24     self.declareParameter(domain=None, x_c=numarray.zeros([3]),A=1.,width=0.1,r=0)
25    
26     def out(self):
27     x=self.domain.getX()
28     dim=self.domain.getDim()
29     l=length(x-self.x_c[:dim])
30     m=(l-self.r).whereNegative()
31     return (m+(1.-m)*exp(-log(2.)*(l/self.width)**2))*self.A
32    
33     class InterpolatedTimeProfile(Model):
34     """ """
35    
36     def __init__(self,debug=False):
37     Model.__init__(self,debug=debug)
38     self.declareParameter(t=[0.,1.],\
39     values=[1.,1.],\
40     out=0.)
41     def doInitialization(self,t):
42     self.__tn=t
43    
44     def doStep(self,dt):
45     t=self.__tn+dt
46     if t<=self.t[0]:
47     self.out=self.values[0]
48     else:
49     for i in range(1,len(self.t)):
50     if t<self.t[i]:
51     m=(self.values[i-1]-self.values[i])/(self.t[i-1]-self.t[i])
52     self.out=m*(t-self.t[i-1])+self.values[i-1]
53     self.out=self.t[len(self.t)-1]
54     self.__tn+=dt

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26