Example #1
0
 def set_cilyndrical_components(self):
     self.data['r'] = (self['x']**2 + self['y']**2)**0.5
     self.data['vrad'], self.data['vtan'] = uv2nt(self['x'],
                                                  self['y'],
                                                  self['u'],
                                                  self['v'],
                                                  x_c=self.center['x'],
                                                  y_c=self.center['y'])
Example #2
0
    def cost(self, p, x, y, u, v):
        """
        """
        # I'm not sure this is the best way to count the number of elements.
        n = len(u.compressed().flatten())

        s = self.s
        vr, vt = uv2nt(x, y, u, v, x_c=s[0]*p[0], y_c=s[1]*p[1])
        mag = (u**2+v**2)**0.5
        j = 1./(2*n)*ma.sum( (vr/mag)**2 )
        return j
Example #3
0
    def cost(self, p, dt, x, y, u, v):
        """
        """
        # I'm not sure this is the best way to count the number of elements.
        n = len(u.compressed().flatten())

        s = self.s
        u_new = u - s[2]*p[2]
        v_new = v - s[3]*p[3]
        x_new = x - dt*s[2]*p[2]
        y_new = y - dt*s[2]*p[3]
        vr, vt = uv2nt(x_new, y_new, u_new, v_new, x_c=s[0]*p[0], y_c=s[1]*p[1])
        mag = (u**2+v**2)**0.5
        #vt = -u*ma.sin(ma.arctan2(y-p[1], x-p[0])) + \
        #      v*ma.cos(ma.arctan2(y-p[1], x-p[0]))
        # Maybe
        #e = 1./(2*n)*ma.sum( vr**2/mag )

        j = 1./(2*n)*ma.sum( (vr/mag)**2 ) + \
                self.lamb/2 * (s[2]*p[2]**2 + s[3]*p[3]**2)
        return j
Example #4
0
 def set_cilyndrical_components(self):
     self.data['r'] = (self['x'] ** 2 + self['y'] ** 2) ** 0.5
     self.data['vrad'], self.data['vtan'] = uv2nt(self['x'], self['y'],
             self['u'], self['v'],
             x_c=self.center['x'], y_c=self.center['y'])