Exemplo n.º 1
0
 def solve(self, property):
     #should solve through parameters
     self.property = property
     for shiftmode in range(len(self.scan_parameters.shiftmoderange)):
         for gap in range(len(self.scan_parameters.gaprange)):
             for shift in range(len(self.scan_parameters.shiftrange)):
                 #set the specific case solution
                 print ('Calculating stuff for model at gap {} mm, shift {} mm, mode {}'.format(
                     self.scan_parameters.gaprange[gap], 
                     self.scan_parameters.shiftrange[shift], 
                     self.scan_parameters.shiftmoderange[shiftmode]))
                 self.hyper_params.gap = self.scan_parameters.gaprange[gap]
                 self.hyper_params.rowshift = self.scan_parameters.shiftrange[shift]
                 self.hyper_params.shiftmode = self.scan_parameters.shiftmoderange[shiftmode]
                 
                 time1 = time.time()
                 #build the case models
                 casemodel = id.compensatedAPPLEv2(self.hyper_params)
                 time2 = time.time()
                 #solve the case model
                 casesol = CaseSolution(casemodel)
                 time3 = time.time()
                 #solve each type of calculation
                 if 'B' in self.property:
                     casesol.calculate_B_field()
                     print ('The peak field of this arrangement is {}'.format(casesol.bmax))
                     self.results['Bmax'][shiftmode,gap,shift] = casesol.bmax
                     self.results['Bfield'][shiftmode,gap,shift] = casesol.bfield
                 
                 if 'Integrals' in self.property:
                     casesol.calculate_first_integral()
                     casesol.calculate_second_integral()
                     
                 if 'Forces' in self.property:
                     casesol.calculate_force_per_magnet()
                     self.results['Force_Per_Magnet_Type'][shiftmode,gap,shift] = casesol.magnetforces
                     casesol.calculate_force_per_row()
                     casesol.calculate_force_per_quadrant()
                     casesol.calculate_force_per_beam()
                     
                     #print ('The force on this arrangement is {}'.format(casesol.beamforces[0]))
                     #load results into the solution
                     
                     self.results['Force_Per_Row'][shiftmode,gap,shift] = casesol.rowforces
                     self.results['Force_Per_Beam'][shiftmode,gap,shift] = casesol.beamforces
                     self.results['Force_Per_Quadrant'][shiftmode,gap,shift] = casesol.quadrantforces
                     #np.array([casesol.forceonquadrants['force_on_quadrant_1'],
                     #                                                                casesol.forceonquadrants['force_on_quadrant_2'],
                     #                                                                casesol.forceonquadrants['force_on_quadrant_3'],
                     #                                                                casesol.forceonquadrants['force_on_quadrant_4']])
                 time4 = time.time()
                 
                 print('time to build case model is {}'.format(time2-time1))
                 print('time to solve case model is {}'.format(time3-time2))
                 print('time to calculate case model is {}'.format(time4-time3))
                 
                 
                 self.case_solutions.append(casesol)
Exemplo n.º 2
0
                                             periods = 1, 
                                             periodlength = 15,
                                             nominal_fmagnet_dimensions = [15.0,0.0,15.0], 
                                             #nominal_cmagnet_dimensions = [10.0,0.0,15.0],
                                             nominal_vcmagnet_dimensions = [7.5,0.0,12.5],
                                             nominal_hcmagnet_dimensions = [7.5,0.0,15.0], 
                                             compappleseparation = 7.5,
                                             apple_clampcut = 3.0,
                                             comp_magnet_chamfer = [3.0,0.0,3.0],
                                             magnets_per_period = 6,
                                             gap = 2, 
                                             rowshift = 0,
                                             shiftmode = 'circular',
                                             block_subdivision = [1,1,1]
                                             )
    a = id.compensatedAPPLEv2(test_hyper_params)
#    
    case1 = CaseSolution(a)
    case1.calculate_B_field()
    print(case1.bmax)
    print(1)
#    case1.calculate_force_per_beam()
#    case1.calculate_force_per_quadrant()
#    case1.calculate_force_per_row()
    
#    case1.case_save(False, 'Single_Case', fname = 'M:\Work\Athena_APPLEIII\Python\Results\\casedev210210.h5')
#    
    #draw object
#    rd.ObjDrwOpenGL(a.cont.radobj)
    
#    plt.plot(case1.bfield[:,0],case1.bfield[:,1:4])
Exemplo n.º 3
0
        Mova=20,
        periods=1,
        periodlength=15,
        nominal_fmagnet_dimensions=[15.0, 0.0, 15.0],
        #nominal_cmagnet_dimensions = [10.0,0.0,15.0],
        nominal_vcmagnet_dimensions=[7.5, 0.0, 12.5],
        nominal_hcmagnet_dimensions=[7.5, 0.0, 15.0],
        compappleseparation=7.5,
        apple_clampcut=3.0,
        comp_magnet_chamfer=[3.0, 0.0, 3.0],
        magnets_per_period=6,
        gap=2.2,
        rowshift=7.5,
        shiftmode='circular',
        block_subdivision=[1, 1, 1])

    #make list of parameter sets to cycle through. In this case H and then V
    param_sets = [ATH_II_hp_horz, ATH_II_hp_vert]

    #cycle through sets
    for model in param_sets:
        #create model
        this_id = id.compensatedAPPLEv2(model)
        #solve model
        this_id.cont.wradSolve()

        #plot XZ streams
        XY_field_sheet(this_id, linewidth=1)

    input("Press Enter to continue...")