/[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 4212 by jfenwick, Tue Jan 22 09:30:23 2013 UTC revision 4213 by caltinay, Tue Feb 19 01:16:29 2013 UTC
# Line 104  class ForwardModelWithPotential(ForwardM Line 104  class ForwardModelWithPotential(ForwardM
104          self.__pde.setSymmetryOn()          self.__pde.setSymmetryOn()
105          z=x[DIM-1]          z=x[DIM-1]
106          self.__pde.setValue(q=whereZero(z-BX[DIM-1][1]))          self.__pde.setValue(q=whereZero(z-BX[DIM-1][1]))
107            
108          self.edge_lengths=np.asarray(boundingBoxEdgeLengths(domain))          self.edge_lengths=np.asarray(boundingBoxEdgeLengths(domain))
109          self.diameter=1./sqrt(sum(1./self.edge_lengths**2))          self.diameter=1./sqrt(sum(1./self.edge_lengths**2))
110            
111      def _rescaleWeights(self, scale=1., fetch_factor=1.):      def _rescaleWeights(self, scale=1., fetch_factor=1.):
112          """          """
113          rescales the weights such that          rescales the weights such that
114            
115          *sum_s integrate( ( weight_i[s] *data_i[s]) (weight_j[s]*1/L_j) * L**2 * fetch_factor )=scale*          *sum_s integrate( ( weight_i[s] *data_i[s]) (weight_j[s]*1/L_j) * L**2 * fetch_factor )=scale*
116          """          """
117          if not scale > 0:          if not scale > 0:
# Line 124  class ForwardModelWithPotential(ForwardM Line 124  class ForwardModelWithPotential(ForwardM
124              for s in xrange(len(self.__weight)):  self.__weight[s]*=A              for s in xrange(len(self.__weight)):  self.__weight[s]*=A
125          else:          else:
126              raise ValueError("Rescaling of weights failed.")              raise ValueError("Rescaling of weights failed.")
127          
128      def useSphericalCoordinates(self):      def useSphericalCoordinates(self):
129          """          """
130          Returns ``True`` if spherical coordinates are used.          Returns ``True`` if spherical coordinates are used.
# Line 210  class GravityModel(ForwardModelWithPoten Line 210  class GravityModel(ForwardModelWithPoten
210    
211          self.__G = gravity_constant          self.__G = gravity_constant
212          self.getPDE().setValue(A=kronecker(self.getDomain()))          self.getPDE().setValue(A=kronecker(self.getDomain()))
213        
214      def rescaleWeights(self, scale=1., rho_scale=1.):      def rescaleWeights(self, scale=1., rho_scale=1.):
215          """          """
216          rescales the weights such that          rescales the weights such that
217            
218          *sum_s integrate( ( w_i[s] *g_i[s]) (w_j[s]*1/L_j) * L**2 * 4*pi*G*rho_scale )=scale*          *sum_s integrate( ( w_i[s] *g_i[s]) (w_j[s]*1/L_j) * L**2 * 4*pi*G*rho_scale )=scale*
219            
220          :param scale: scale of data weighting factors          :param scale: scale of data weighting factors
221          :type scale: positive ``float``          :type scale: positive ``float``
222          :param rho_scale: scale of density.          :param rho_scale: scale of density.
223          :type rho_scale: ``Scalar``          :type rho_scale: ``Scalar``
224          """          """
225          self._rescaleWeights(scale, 4.*PI*self.__G*rho_scale)          self._rescaleWeights(scale, 4.*PI*self.__G*rho_scale)
226          
227      def getArguments(self, rho):      def getArguments(self, rho):
228          """          """
229          Returns precomputed values shared by `getValue()` and `getGradient()`.          Returns precomputed values shared by `getValue()` and `getGradient()`.
# Line 311  class MagneticModel(ForwardModelWithPote Line 311  class MagneticModel(ForwardModelWithPote
311          super(MagneticModel, self).__init__(domain, w, B, useSphericalCoordinates, tol)          super(MagneticModel, self).__init__(domain, w, B, useSphericalCoordinates, tol)
312          self.__background_magnetic_flux_density=interpolate(background_magnetic_flux_density, B[0].getFunctionSpace())          self.__background_magnetic_flux_density=interpolate(background_magnetic_flux_density, B[0].getFunctionSpace())
313          self.getPDE().setValue(A=kronecker(self.getDomain()))          self.getPDE().setValue(A=kronecker(self.getDomain()))
314            
315      def rescaleWeights(self, scale=1., k_scale=1.):      def rescaleWeights(self, scale=1., k_scale=1.):
316          """          """
317          rescales the weights such that          rescales the weights such that
318            
319          *sum_s integrate( ( w_i[s] *B_i[s]) (w_j[s]*1/L_j) * L**2 * (background_magnetic_flux_density_j[s]*1/L_j) * k_scale )=scale*          *sum_s integrate( ( w_i[s] *B_i[s]) (w_j[s]*1/L_j) * L**2 * (background_magnetic_flux_density_j[s]*1/L_j) * k_scale )=scale*
320            
321          :param scale: scale of data weighting factors          :param scale: scale of data weighting factors
322          :type scale: positive ``float``          :type scale: positive ``float``
323          :param k_scale: scale of susceptibility.          :param k_scale: scale of susceptibility.
324          :type k_scale: ``Scalar``            :type k_scale: ``Scalar``
325          """          """
326          self._rescaleWeights(scale, inner(self.__background_magnetic_flux_density,1/self.edge_lengths ) * k_scale)          self._rescaleWeights(scale, inner(self.__background_magnetic_flux_density,1/self.edge_lengths ) * k_scale)
327            
328      def getArguments(self, k):      def getArguments(self, k):
329          """          """
330          Returns precomputed values shared by `getValue()` and `getGradient()`.          Returns precomputed values shared by `getValue()` and `getGradient()`.

Legend:
Removed from v.4212  
changed lines
  Added in v.4213

  ViewVC Help
Powered by ViewVC 1.1.26