/[escript]/trunk/downunder/py_src/forwardmodels.py
ViewVC logotype

Diff of /trunk/downunder/py_src/forwardmodels.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4078 by caltinay, Fri Nov 16 04:31:02 2012 UTC revision 4079 by gross, Fri Nov 16 07:59:01 2012 UTC
# Line 94  class ForwardModelWithPotential(ForwardM Line 94  class ForwardModelWithPotential(ForwardM
94          for s in xrange(len(self.__weight)):          for s in xrange(len(self.__weight)):
95              A += integrate(inner(self.__weight[s], self.__data[s]**2))              A += integrate(inner(self.__weight[s], self.__data[s]**2))
96          if A > 0:          if A > 0:
97              for s in xrange(len(self.__weight)):  self.__weight[s]*=1./A          A=vol(domain)/A
98                for s in xrange(len(self.__weight)):  self.__weight[s]*=A
99                print "FORWARD SCALE = ",self.__weight[0]
100          else:          else:
101              raise ValueError("No non-zero data contribution found.")              raise ValueError("No non-zero data contribution found.")
102    
# Line 105  class ForwardModelWithPotential(ForwardM Line 107  class ForwardModelWithPotential(ForwardM
107          self.__pde=LinearSinglePDE(domain)          self.__pde=LinearSinglePDE(domain)
108          self.__pde.getSolverOptions().setTolerance(tol)          self.__pde.getSolverOptions().setTolerance(tol)
109          self.__pde.setSymmetryOn()          self.__pde.setSymmetryOn()
110          self.__pde.setValue(q=whereZero(x[DIM-1]-BX[DIM-1][1]))          #self.__pde.setValue(q=whereZero(x[DIM-1]-BX[DIM-1][1]))
111            self.__pde.setValue(q=whereZero(x[DIM-1]-BX[DIM-1][1])+whereZero(x[DIM-1]-BX[DIM-1][0]))
112      def getDomain(self):      def getDomain(self):
113          """          """
114          Returns the domain of the forward model.          Returns the domain of the forward model.
# Line 131  class ForwardModelWithPotential(ForwardM Line 133  class ForwardModelWithPotential(ForwardM
133          """          """
134          A=0.          A=0.
135          for s in xrange(len(self.__weight)):          for s in xrange(len(self.__weight)):
136              A = inner(self.__weight[s], (result-self.__data[s])**2) + A              A += integrate(inner(self.__weight[s], (result-self.__data[s])**2))
137          return 0.5*integrate(A)          return A/2
138    
139      def getSurvey(self, index=None):      def getSurvey(self, index=None):
140          """          """
# Line 267  class MagneticModel(ForwardModelWithPote Line 269  class MagneticModel(ForwardModelWithPote
269          :type tol: positive ``float``          :type tol: positive ``float``
270          """          """
271          super(MagneticModel, self).__init__(domain, chi, B, tol)          super(MagneticModel, self).__init__(domain, chi, B, tol)
272            print "B = ",B[0]
273            print "background_field = ",background_field
274            
275          self.__background_field=interpolate(background_field, B[0].getFunctionSpace())          self.__background_field=interpolate(background_field, B[0].getFunctionSpace())
276          self.getPDE().setValue(A=kronecker(self.getDomain()))          self.getPDE().setValue(A=kronecker(self.getDomain()))
277    
# Line 341  class MagneticModel(ForwardModelWithPote Line 346  class MagneticModel(ForwardModelWithPote
346          #saveVTK("Y.vtu",RHS=pde.getRightHandSide(), Y=Y)          #saveVTK("Y.vtu",RHS=pde.getRightHandSide(), Y=Y)
347    
348          YT=pde.getSolution()          YT=pde.getSolution()
349            print "YT = ",YT
350          return inner(Y-grad(YT),self.__background_field)          return inner(Y-grad(YT),self.__background_field)
351    

Legend:
Removed from v.4078  
changed lines
  Added in v.4079

  ViewVC Help
Powered by ViewVC 1.1.26