Exemplo n.º 1
0
    def ddu(self):

        dudr_mat    =   self.dudrpol
        dudphi_mat  =   self.dudphipol  

        dr_mat_r    =   self.dr_mat
        dphi_mat_phi=   np.delete(self.dphi_mat, -1, 1)
        
        ddudrdr     =   (np.delete(dudr_mat,    0, 0)   \
                        -np.delete(dudr_mat,   -1, 0))  /  np.delete(dr_mat_r, -1 ,0)
        
        ddudrdphi   =   (np.delete(dudr_mat,    0, 1)   \
                        -np.delete(dudr_mat,   -1, 1))  /  np.delete(dphi_mat_phi, -1 ,0)
        
        
        ddudphidr   =   (np.delete(dudphi_mat,  0, 0)   \
                        -np.delete(dudphi_mat, -1, 0))  /  dr_mat_r
                         
        ddudphidphi =   (np.delete(dudphi_mat,  0, 1)   \
                        -np.delete(dudphi_mat, -1, 1))  /  dphi_mat_phi
        

        self.ddudrdr        =   ddudrdr
        self.ddudrdphi      =   np.delete(make_periodic_der(ddudrdphi, -1), 0, 0)
        self.ddudphidr      =   np.delete(ddudphidr, 0, 0)
        self.ddudphidphi    =   np.delete(np.delete(make_periodic_der(ddudphidphi, -1), 0, 0), -1, 0)
            
        self.ddudrdrcart    = np.empty(self.phys_surf.shape, dtype = 'object')
        self.ddudrdphicart  = np.empty(self.phys_surf.shape, dtype = 'object')
        self.ddudphidrcart  = np.empty(self.phys_surf.shape, dtype = 'object')
        self.ddudphidphicart= np.empty(self.phys_surf.shape, dtype = 'object')
        
        dudr_mat, dudphi_mat    =   self.get_du()[:2]
        
        for ir, rvec in np.ndenumerate(self.phys_surf):
            
            r, phi              =   rvec[:2]
            ur, uphi            =   self.phys_umat[ir][:2]    
            rp, phip            =   r + ur, phi + uphi
            durdr, duphidr      =   dudr_mat[ir][0], dudr_mat[ir][1]
            durdphi, duphidphi  =   dudphi_mat[ir][0], dudphi_mat[ir][1] #[:2] # self.get_du()[1][ir]
            
            ddurdrdr, dduphidrdr, dduzdrdr          =   self.ddudrdr[ir]
            ddurdphidr, dduphidphidr, dduzdphidr    =   self.ddudphidr[ir]
            ddurdrdphi, dduphidrdphi, dduzdrdphi    =   self.ddudrdphi[ir]
            ddurdphidphi, dduphidphidphi, dduzdphidphi  =   self.ddudphidphi[ir]
            
            
            self.ddudrdrcart[ir]        = np.zeros(3)
            self.ddudphidrcart[ir]      = np.zeros(3)
            self.ddudrdphicart[ir]      = np.zeros(3)
            self.ddudphidphicart[ir]    = np.zeros(3)
            
            
            self.ddudrdrcart[ir][0]     = ddurdrdr*np.cos(phip) - 2*(1 + durdr)*duphidr*np.sin(phip) \
                                            - rp*(duphidr**2*np.cos(phip) + dduphidrdr*np.sin(phip))
            
            self.ddudrdrcart[ir][1]     = ddurdrdr*np.sin(phip) + 2*(1 + durdr)*duphidr*np.cos(phip) \
                                            - rp*(duphidr**2*np.sin(phip) - dduphidrdr*np.cos(phip))
            
            self.ddudrdrcart[ir][2]     = dduzdrdr
            
            
            self.ddudphidrcart[ir][0]   = ddurdphidr*np.cos(phip) - (1 + durdr)*(1 + duphidphi) \
                                        * np.sin(phip) - durdphi*duphidr*np.sin(phip)   \
                                        - rp*((1 + duphidphi)*duphidr*np.cos(phip)      \
                                        + dduphidphidr*np.sin(phip)) + np.sin(phi) 
            
            self.ddudphidrcart[ir][1]   = ddurdphidr*np.sin(phip) + (1 + durdr)*(1 + duphidphi) \
                                        * np.cos(phip) + durdphi*duphidr*np.cos(phip)   \
                                        - rp*(duphidr*(1 + duphidphi)*np.sin(phip)      \
                                        - dduphidphidr*np.cos(phip)) - np.cos(phi)
            
            self.ddudphidrcart[ir][2]   = dduzdphidr
            
            
            self.ddudrdphicart[ir][0]   = ddurdrdphi*np.cos(phip) - (1 + durdr)*(1 + duphidphi) \
                                        * np.sin(phip) - durdphi*duphidr*np.sin(phip)   \
                                        - rp*((1 + duphidphi)*duphidr*np.cos(phip)      \
                                        + dduphidrdphi*np.sin(phip)) + np.sin(phi) 
            self.ddudrdphicart[ir][1]   = ddurdrdphi*np.sin(phip) + (1 + durdr)*(1 + duphidphi) \
                                        * np.cos(phip) + durdphi*duphidr*np.cos(phip)   \
                                        - rp*(duphidr*(1 + duphidphi)*np.sin(phip)      \
                                        - dduphidrdphi*np.cos(phip)) - np.cos(phi)
            self.ddudrdphicart[ir][2]   = dduzdrdphi
            
            
            
            self.ddudphidphicart[ir][0] = ddurdphidphi*np.cos(phip) - durdphi*(1 + duphidphi)   \
                                        * np.sin(phip) - durdphi*(1 + duphidphi)*np.sin(phip)   \
                                        - rp*(dduphidphidphi*np.sin(phip)                       \
                                        + (1 + duphidphi)**2*np.cos(phip)) + r*np.cos(phi) 
            self.ddudphidphicart[ir][1] = ddurdphidphi*np.sin(phip) + durdphi*(1 + duphidphi)   \
                                        * np.cos(phip) + durdphi*(1 + duphidphi)*np.cos(phip)   \
                                        + rp*(dduphidphidphi*np.cos(phip)                       \
                                        - (1 + duphidphi)**2*np.sin(phip)) + r*np.sin(phi)
            self.ddudphidphicart[ir][2] = dduzdphidphi
Exemplo n.º 2
0
    def du(self):
        
        
#        r_mat                   =   make_periodic_surf(self.ext_surf, self.phi_period)
        r_mat                   =   make_periodic(self.ext_surf, 'surf', phi_period = self.phi_period)
 
        u_mat_pol               =   make_periodic(self.ext_umat, 'umat', sym_op = self.sym_op)
          
        dr_mat                  =   np.delete(r_mat, 0, 0)  - np.delete(r_mat, -1, 0) 
        dphi_mat                =   np.delete(r_mat, 0, 1)  - np.delete(r_mat, -1, 1)   
        
        dr_mat_r                =   np.empty(dr_mat.shape)
        dphi_mat_phi            =   np.empty(dphi_mat.shape)
        
        
        for ir,dr in np.ndenumerate(dr_mat):
            dr_mat_r[ir]        =   dr[0]
        
        for iphi, dphi in np.ndenumerate(dphi_mat):   
            dphi_mat_phi[iphi]  =   dphi[1]
        
        
        dudrpol            =   (np.delete(u_mat_pol,  0, 0)   \
                               -np.delete(u_mat_pol, -1, 0))  / dr_mat_r 
        dudphipol          =   (np.delete(u_mat_pol,  0, 1)   \
                               -np.delete(u_mat_pol, -1, 1))  / dphi_mat_phi  
        
        self.dr_mat        =   dr_mat_r
        self.dphi_mat      =   make_periodic_der(dphi_mat_phi, 1, nums = True)
        
        self.dudrpol       =   dudrpol
        
        self.dudphipol     =   make_periodic_der(dudphipol)
        
        # testi
        dudrcart           =   np.empty(self.dr_mat.shape, dtype = 'object')
        dudphicart         =   np.empty(self.dphi_mat.shape, dtype = 'object')
            
        
        for ind, vec in np.ndenumerate(self.dr_mat):
            dudrcart[ind]      =   np.zeros(3)
            
            r, phi                  =   r_mat[ind][:2] #self.ext_surf[ind][:2]
            #rp, phip                =   r + self.ext_umat[ind][0], phi + self.ext_umat[ind][1]
            rp, phip                =   r + u_mat_pol[ind][0], phi + u_mat_pol[ind][1] 
            durdr, duphidr, duzdr   =   self.dudrpol[ind] 
            
            dudrcart[ind][0]   =  -np.cos(phi) - rp*duphidr*np.sin(phip) \
                                       +(1 + durdr)*np.cos(phip) 
            dudrcart[ind][1]   =  -np.sin(phi) + rp*duphidr*np.cos(phip) \
                                       +(1 + durdr)*np.sin(phip) 
            dudrcart[ind][2]   =   duzdr

        for ind, vec in np.ndenumerate(self.dphi_mat):
            dudphicart[ind]    =   np.zeros(3)
            
            r, phi                  =   r_mat[ind][:2] #self.ext_surf[ind][:2]
            #rp, phip                =   r + self.ext_umat[ind][0], phi + self.ext_umat[ind][1] 
            rp, phip                =   r + u_mat_pol[ind][0], phi + u_mat_pol[ind][1] 
            
            durdphi, duphidphi, duzdphi \
                                    =   self.dudphipol[ind] 
            
            dudphicart[ind][0] =   r*np.sin(phi) + np.cos(phip)*durdphi \
                                       -rp*(1 + duphidphi)*np.sin(phip)   
            dudphicart[ind][1] =  -r*np.cos(phi) + np.sin(phip)*durdphi \
                                       +rp*(1 + duphidphi)*np.cos(phip)   
            dudphicart[ind][2] =   duzdphi
        
        
        self.dudrcart           =   dudrcart
        self.dudphicart         =   dudphicart