コード例 #1
0
ファイル: strain.py プロジェクト: TopiKo/Futurama
def parse_u_from_file(in_file):  
    
    from bender_rw import parse_input
    from surface import surf
    
    param_set           =   parse_input(in_file)
    system              =   param_set["system"]
    nr, nphi            =   param_set["nr"],    param_set["nphi"]
    rmin, rmax          =   param_set["rmin"],  param_set["rmax"]
    phimin, phi_period  =   param_set["phimin"],param_set["phiperiod"] 
    height              =   param_set["height"]
    #moldy_opm           =   param_set["moldy_opm"]
    
    hangle              =   height / 2 / pi   
    asurf               =   surf(rmin, rmax, nr, phimin, phi_period, nphi)
    ue                  =   u(hangle, phi_period, asurf.get_all_surf(), \
                              system = system)
    
    return ue       
   
    
コード例 #2
0
ファイル: tests.py プロジェクト: TopiKo/Futurama
 def tests(self, param_set):
     
     from strain import u
     
     system              =   param_set["system"]
     nr, nphi            =   param_set["nr"], param_set["nphi"]
     rmin, rmax          =   param_set["rmin"], param_set["rmax"]
     phimin, phi_period  =   param_set["phimin"], param_set["phiperiod"] 
     height              =   param_set["height"]
     consts              =   param_set["consts"]
     hangle              =   height / 2 / pi   
 
     init_surf           =   surf(rmin, rmax, nr, phimin, phi_period, nphi)
     
     ue                  =   u(hangle, phi_period, init_surf.get_all_surf(), \
                                           system = system)
     
     energies            =   deform_energies(u = ue, bend_module = self.bm,\
                                 strech_module = self.sm, sigma = self.sigma)
     
     
     E_b, E_s, E_b_surf, E_s_surf, normals \
                         =   energies.calc_energies(consts)
     alpha               =   consts[0]
         
     
     if system == 'cup':
         
         print '\nThis is cup with uz = alpha/2*R**2'
         print 'code E_b                      = ' + str(E_b) 
         print 'analytical E_b (small alpha!) = ' + str(1./2.*phi_period*self.bm*alpha**2*(rmax**2 - rmin**2)*(2./(1.-self.sigma) - 1.)) # kuppi, bend
         print 'code E_s                      = ' + str(E_s) 
         print 'analytical E_s (small alpha!) = ' + str(self.sm/8.*alpha**4*phi_period/(1.-self.sigma)*1./6.*(rmax**6 - rmin**6))
     
     elif system == 'spiral':
     
         print '\nThis is spiral with uz = hangle*phi'
         print 'code E_b                      = ' + str(E_b) 
         print 'analytical E_b (small hangle!)= ' + str(self.bm*hangle**2*phi_period/2. \
                                                        *(1./rmin**2 - 1./rmax**2)) 
         print 'code E_s                      = ' + str(E_s)
         print 'analytical E_s (small hangle!)= ' + str(self.sm*hangle**4/(2*(1 - self.sigma))*phi_period/8. \
                                                        *(1./rmin**2 - 1./rmax**2))
     
     elif system == 'screw':
         
         print '\nThis is screw with uz = hangle*phi + r*alpha'
         print 'code E_b                      = ' + str(E_b) 
         print 'analytical E_b (small hangle!)= ' + str(self.bm*phi_period*(hangle**2/2*(1./rmin**2 - 1./rmax**2) \
                                                             + 1./(2*(1 - self.sigma))*alpha**2*np.log(rmax/rmin)))
         print 'code E_s                      = ' + str(E_s)
         print 'analytical E_s (small hangle!)= ' + str(self.sm/8.*phi_period/(1 - self.sigma)*( \
                                                           alpha**4 / 2. * ( rmax**2  - rmin**2 )                    \
                                                         + 2 * alpha**2 * hangle**2 * np.log( rmax / rmin )    \
                                                         + hangle**4 / 2 * ( 1. / rmin**2 - 1. / rmax**2) ))
     
     elif system == 'ball':
         
         '''
         R          =   10.0
         alpha      =   np.sin(pi/10)
         theta_max  =   np.arcsin(alpha)
         rmax       =   alpha*R
         consts     =   [R, theta_max]
         '''
         
         R                   =   consts[0]
         alpha_max           =   rmax/R
         alpha_min           =   rmin/R
         theta_max           =   np.arcsin(rmax/R)
         theta_min           =   np.arcsin(rmin/R)
         
         # print resutls
         print '\nThis is ball with uz = R - sqrt(R**2 - r**2), from 0 to alpha*R'
         print 'code E_b_density              = ' + str(E_b/(phi_period*R**2*(np.cos(theta_min) - np.cos(theta_max)))) 
         print 'analytical E_b_density        = ' + str(self.bm / R**2 * ( 2. / (1 - self.sigma) - 1 ))
         print 'code E_s                      = ' + str(E_s)
         print 'analytical E_s                = ' + str(self.sm*R**2/(8*(1 - self.sigma))*phi_period* \
                                             (np.log(1 - alpha_max**2) + alpha_max**2/2*(alpha_max**2 - 2)/(alpha_max**2 - 1) \
                                            - np.log(1 - alpha_min**2) - alpha_min**2/2*(alpha_min**2 - 2)/(alpha_min**2 - 1)))
     
     
     
     plot_all(ue.phys_surf, ue.calc_surf, ue.phys_umat, ue.calc_umat, \
              E_b_surf, E_s_surf, normals, path = '', show = True)