Example #1
0
    def dA(self):
        
        self.dA_S               =   np.zeros(self.calc_surf.shape)
        self.dA_P               =   np.zeros(self.calc_surf.shape)
        
        init_surf               =   transform_to_cart(self.phys_surf)
        deformed_surf           =   transform_to_cart(self.phys_surf + self.phys_umat)
        
        for index, val in np.ndenumerate( self.dA_S ):
            i,j = index

            dr_vec_p            =   init_surf[i + 1, j]        -   init_surf[i, j]
            dphi_vec_p1         =   init_surf[i, j + 1]        -   init_surf[i, j]
            dphi_vec_p2         =   init_surf[i + 1, j + 1]    -   init_surf[i + 1, j]
            
            v1p                 =   dr_vec_p                   +   dphi_vec_p1
            v2p                 =   dphi_vec_p2                -   dr_vec_p 
            
            self.dA_P[index]    =   .5*np.linalg.norm(np.cross(v1p, v2p))
            
            dr_vec              =   deformed_surf[i + 1, j]    - deformed_surf[i, j]
            dphi_vec1           =   deformed_surf[i, j + 1]    - deformed_surf[i, j]
            dphi_vec2           =   deformed_surf[i + 1, j + 1]- deformed_surf[i + 1, j]

            v1s                 =   dr_vec        +   dphi_vec1
            v2s                 =   dphi_vec2     -   dr_vec 

            self.dA_S[index]    =   .5*np.linalg.norm(np.cross(v1s, v2s))
Example #2
0
def check(u, e_surf):
    
    screwed_up  =   False 
    
    umat_cart               =   transform_to_cart(u.phys_surf + u.phys_umat) \
                              - transform_to_cart(u.phys_surf)
    
    u_pol, u_cart           =   u.phys_umat, umat_cart #u.umat_cart[1] # u.u(e_surf[i,j], 'upol'), u.u(e_surf[i,j], 'ucart')
    dudr_pol, dudphi_pol, \
    dudr_cart, dudphi_cart =   u.get_du()  #u.du(e_surf[i,j], 'dupol'), u.du(e_surf[i,j], 'ducart')

    
    for ind, r in np.ndenumerate(e_surf):
             
        r, phi                  =   r[:2] #e_surf[i,j][:2]
        
        if abs(dudr_cart[ind][0] - ( dudr_pol[ind][0]*np.cos(phi) - u_pol[ind][1]*np.sin(phi) - r*dudr_pol[ind][1]*np.sin(phi))) > 0.01:
            print 'Alert1'
            #print r, phi, u_der_cart[0,0] - ( u_der_pol[0,0]*np.cos(phi) - u_pol[1]*np.sin(phi) - r*u_der_pol[1,0]*np.sin(phi))
            screwed_up = True
        if abs(dudr_cart[ind][1] - ( dudr_pol[ind][0]*np.sin(phi) + u_pol[ind][1]*np.cos(phi) + r*dudr_pol[ind][1]*np.cos(phi))) > 0.01:
            print 'Alert2'
            #print r, phi
            screwed_up = True               
        if abs(dudphi_cart[ind][0] - ( dudphi_pol[ind][0]*np.cos(phi) - r*dudphi_pol[ind][1]*np.sin(phi) - u_cart[ind][1])) > 0.01:
            print 'Alert3'
            #print r, phi
            screwed_up = True
        if abs(dudphi_cart[ind][1] - ( dudphi_pol[ind][0]*np.sin(phi) + r*dudphi_pol[ind][1]*np.cos(phi) + u_cart[ind][0])) > 0.01:
            print 'Alert4'
            #print r, phi
            screwed_up = True
            
            
            '''
            if abs(u_der_cart[0,0] - ( u_der_pol[0,0]*np.cos(phi) - u_pol[1]*np.sin(phi) - r*u_der_pol[0,1]*np.sin(phi))) > 0.01:
                print 'Alert1'
                #print r, phi, u_der_cart[0,0] - ( u_der_pol[0,0]*np.cos(phi) - u_pol[1]*np.sin(phi) - r*u_der_pol[1,0]*np.sin(phi))
                screwed_up = True
            if abs(u_der_cart[0,1] - ( u_der_pol[0,0]*np.sin(phi) + u_pol[1]*np.cos(phi) + r*u_der_pol[0,1]*np.cos(phi))) > 0.01:
                print 'Alert2'
                #print r, phi
                screwed_up = True               
            if abs(u_der_cart[1,0] - ( u_der_pol[1,0]*np.cos(phi) - r*u_der_pol[1,1]*np.sin(phi) - u_cart[1])) > 0.01:
                print 'Alert3'
                #print r, phi
                screwed_up = True
            if abs(u_der_cart[1,1] - ( u_der_pol[1,0]*np.sin(phi) + r*u_der_pol[1,1]*np.cos(phi) + u_cart[0])) > 0.01:
                print 'Alert4'
                #print r, phi
                screwed_up = True
            '''
    if not screwed_up:
        print 'Derivatives are ok!'
    else:
        print 'derivatives screwqed up...'
        exit(0)