Пример #1
0
if NCPUS is None:
    NCPUS = '10'

for i, Emax in enumerate(Emax_vect):
    current_sim_ident = 'complete_cavity_Emax_'+exps_str[i]
    print(current_sim_ident)
    current_sim_folder = scan_folder+'/'+current_sim_ident
    if not os.path.exists(current_sim_folder):
        os.mkdir(current_sim_folder)
    os.system('cp -r %s %s'%(tobecopied1, current_sim_folder))
    os.system('cp -r %s %s'%(tobecopied2, current_sim_folder))
    os.system('cp -r %s %s'%(tobecopied3, current_sim_folder))

    curr_sim = current_sim_folder+'/transient_sim.py'
    
    rl.replaceline_and_save(fname = curr_sim,
     findln = 'laser_emax = ', newline = 'laser_emax = %1.0e\n'%Emax)
      
    rl.replaceline_and_save(fname = curr_sim,
     findln = "images_dir = ", newline = "images_dir = '" +current_sim_folder+ "/images'\n")

    rl.replaceline_and_save(fname = curr_sim,
     findln = "temps_filename = ", newline = "temps_filename = '"+current_sim_folder+"/transient_temp.h5'\n")

    rl.replaceline_and_save(fname = curr_sim,
     findln = "output_filename = ", newline = "output_filename = '" +current_sim_folder+"/transient_out.h5'\n")

    rl.replaceline_and_save(fname = curr_sim,
     findln = "dump_folder = ", newline = "dump_folder = '" +current_sim_folder+"/dumps'\n")
 
    launch_lines1 = ['bsub -B -N -R "rusage[mem=4096]" -o '
                    + current_sim_folder +
Пример #2
0
    for macroparticles_per_slice in macroparticles_per_slice_vect:

        for betax, betay in zip(betax_vect, betay_vect):

            prog_num += 1
            current_sim_ident = 'ArcQuad_T0_x_slices_750_segments_16_length_%02d_MPslice_%05d_betaxy_%03dm' % (
                fraction_device_quad * 100, macroparticles_per_slice, betax)
            sim_tag = tag_prefix + '%04d' % prog_num

            print sim_tag, current_sim_ident
            current_sim_folder = scan_folder + '/' + current_sim_ident
            os.mkdir(current_sim_folder)
            os.system('cp -r sim_prototype/* %s' % current_sim_folder)

            rl.replaceline_and_save(
                fname=current_sim_folder + '/Simulation_parameters.py',
                findln='fraction_device_quad = ',
                newline='fraction_device_quad = %.2f' % fraction_device_quad)
            rl.replaceline_and_save(fname=current_sim_folder +
                                    '/Simulation_parameters.py',
                                    findln='macroparticles_per_slice = ',
                                    newline='macroparticles_per_slice = %d' %
                                    macroparticles_per_slice)
            rl.replaceline_and_save(fname=current_sim_folder +
                                    '/Simulation_parameters.py',
                                    findln='beta_x = ',
                                    newline='beta_x = %d' % betax)
            rl.replaceline_and_save(fname=current_sim_folder +
                                    '/Simulation_parameters.py',
                                    findln='beta_y = ',
                                    newline='beta_y = %d' % betay)
			for n_slices in n_slices_vect:
				
				prog_num +=1

				current_sim_ident= 'transverse_grid_%s_betaxy_%.0fm_length%.2f_slices_%d'%(PyPICmode_tag, betax,fraction_device_quad,n_slices)                       
				sim_tag = tag_prefix+'%04d'%prog_num


				print sim_tag, current_sim_ident
				current_sim_folder = scan_folder+'/'+current_sim_ident
				os.mkdir(current_sim_folder)

				os.system('cp -r sim_prototype/* %s'%current_sim_folder)
				
				rl.replaceline_and_save(fname = current_sim_folder+'/Simulation_parameters.py',
									findln = 'PyPICmode = ', 
									newline = 'PyPICmode = \'%s\''%PyPICmode)
				rl.replaceline_and_save(fname = current_sim_folder+'/Simulation_parameters.py',
									findln = 'N_min_Dh_main = ', 
									newline = 'N_min_Dh_main = %.1f'%N_min_Dh_main)
				rl.replaceline_and_save(fname = current_sim_folder+'/Simulation_parameters.py',
									findln = 'Dh_sc_ext = ', 
									newline = 'Dh_sc_ext = %.6f'%Dh_sc_ext)
				rl.replaceline_and_save(fname = current_sim_folder+'/Simulation_parameters.py',
									findln = 'f_telescope = ', 
									newline = 'f_telescope = %.1f'%f_telescope)
				rl.replaceline_and_save(fname = current_sim_folder+'/Simulation_parameters.py',
									findln = 'target_size_internal_grid_sigma = ', 
									newline = 'target_size_internal_grid_sigma = %.1f'%target_size_internal_grid_sigma)
				rl.replaceline_and_save(fname = current_sim_folder+'/Simulation_parameters.py',
									findln = 'target_Dh_internal_grid_sigma = ', 
Пример #4
0
launch_file_lines = []
launch_file_lines += ['#!/bin/bash\n']

Emax_vect = np.linspace(0, 55e6, 12)

prog_num = 0
for Emax in Emax_vect:
    prog_num += 1
    current_sim_ident = 'complete_cavity_Emax_' + str(Emax / 1e6)
    print(current_sim_ident)
    current_sim_folder = scan_folder + '/' + current_sim_ident
    os.mkdir(current_sim_folder)

    rl.replaceline_and_save(fname='complete_sim.py',
                            findln='E_field_max = ',
                            newline='E_field_max = %d,\n' % Emax)

    rl.replaceline_and_save(fname='complete_sim.py',
                            findln="'images_dir': ",
                            newline="\t'images_dir': '" + current_sim_folder +
                            "/images',\n")

    rl.replaceline_and_save(fname='complete_sim.py',
                            findln="'temps_filename': ",
                            newline="\t'temps_filename': '" +
                            current_sim_folder + "/complete_temp.mat',\n")

    rl.replaceline_and_save(fname='complete_sim.py',
                            findln="'output_filename': ",
                            newline="\t'output_filename': '" +
Пример #5
0
#os.mkdir()

#GENERATION OF FOLDERS FOR THE SIMS AND COMPILATION OF THE APPLICATION

sdirname1 = "leather_sim_"
sdirname2 = "_keV"

#Creation of the simulation dirs

curr_dir = os.getcwd()
parent_dir = curr_dir + "/simulations"
srcfiles_dir = curr_dir + "/PDB_OF"
os.mkdir(srcfiles_dir)

rl.replaceline_and_save(
    fname=curr_dir + "/pdb4dna_sourcefiles/src/DetectorConstruction.cc",
    findln="G4double world_x_size =",
    newline="G4double world_x_size = " + str(world_x_length) + "*1*angstrom;")

rl.replaceline_and_save(
    fname=curr_dir + "/pdb4dna_sourcefiles/src/DetectorConstruction.cc",
    findln="G4double world_y_size =",
    newline="G4double world_y_size = " + str(world_y_length) + "*1*angstrom;")

rl.replaceline_and_save(
    fname=curr_dir + "/pdb4dna_sourcefiles/src/DetectorConstruction.cc",
    findln="G4double world_z_size =",
    newline="G4double world_z_size = " + str(world_z_length) + "*1*angstrom;")

#Copy of the geometry file and compilation of the Geant4 Application

sht.copyfile(curr_dir + "/geometry.pdb", srcfiles_dir + "/geometry.pdb")
def one_pinch(mydict, lock, N_pinches=1, save_sigmas_and_coords=False, idd=0, grid=None, state_list=None):
    os.mkdir('temp'+str(idd))
    shutil.copytree('pyecloud_config', 'temp'+str(idd)+'/pyecloud_config')
    shutil.copyfile('Simulation_parameters.py', 'temp'+str(idd)+'/Simulation_parameters.py')
    shutil.copyfile('LHC_chm_ver.mat', 'temp'+str(idd)+'/LHC_chm_ver.mat')
    os.chdir('temp'+str(idd))
    if os.path.exists('simulation_status.sta'):
        os.remove('simulation_status.sta')
    
    newline=f'filename_init_MP_state_quad = {state_list[idd]}'
    if state_list is not None:
        replaceline_and_save('Simulation_parameters.py', findln='filename_init_MP_state_quad', newline=f'filename_init_MP_state_quad = {state_list[idd]}')

    ring = sim_mod.get_serial_CPUring()
    
    list_slice_objects = ring.pieces_to_be_treated # Head is the last element
    list_machine_elements = ring.sim_content.mypart
    # Truck the beam to the first ecloud (excluded)
    for ee in list_machine_elements:
        if ee in ring.sim_content.my_list_eclouds:
            first_ecloud = ee
            break
        for ss in list_slice_objects[::-1]:
            ee.track(ss)
    
    # Record pinch info
    first_ecloud.save_ele_distributions_last_track = True
#    first_ecloud.save_ele_field = True
    first_ecloud.save_ele_potential = True
    
    first_ecloud._reinitialize() # Needed to prepare storage space
    

    N_slices = len(list_slice_objects)
    z_centers = []
    t_start = time.mktime(time.localtime())
    for i_ss, ss in enumerate(list_slice_objects[::-1]):
        if np.mod(i_ss, 20)==0:
            print("%d / %d"%(i_ss, N_slices))
        first_ecloud.track(ss)
        if ss.slice_info != 'unsliced':
            z_centers.append(ss.slice_info['z_bin_center'])
    
    first_ecloud._finalize()
    z_centers = z_centers[::-1] # HEADTAIL convention
    
    t_end = time.mktime(time.localtime())
    
    print('Track time %.2f s' % (t_end - t_start))

    while 1:
        if len([temp_dirs for temp_dirs in os.listdir('.') if 'temp' in temp_dirs]) < 110:
            break
        else:
            time.sleep(60)
   
    if save_sigmas_and_coords:
        grid['sigma_x_beam'] = ring.sim_content.bunch.sigma_x()
        grid['sigma_y_beam'] = ring.sim_content.bunch.sigma_y()
        grid['sigma_z_beam'] = ring.sim_content.bunch.sigma_z()
        grid['xg'] = first_ecloud.spacech_ele.xg
        grid['yg'] = first_ecloud.spacech_ele.yg
        grid['zg'] = z_centers

    first_ecloud.phi_ele_last_track /= (1.*N_pinches)
    first_ecloud.rho_ele_last_track /= (1.*N_pinches)
    lock.acquire()
    if 'phi' in mydict.keys():
        mydict['phi'] += first_ecloud.phi_ele_last_track
        mydict['rho'] += first_ecloud.rho_ele_last_track
    else:
        mydict['phi'] = first_ecloud.phi_ele_last_track
        mydict['rho'] = first_ecloud.rho_ele_last_track
    lock.release()

    os.chdir('..')
  
    return idd
Пример #7
0
            #sigmaz = beam['sigmaz']
            config = device['config'][beam_name]
            for fact_beam in fact_beam_vect:
                for del_max in del_max_vect:
                    for bl_4_sigma_s in bl_4_sigma_s_vect:
                        prog_num += 1
                        current_sim_ident = '%s_%s_%s_sey%1.2f_%.1fe11ppb_bl_%.2fns' % (
                            machine_name, device_name, beam_name, del_max,
                            fact_beam / 1e11, bl_4_sigma_s / 1e-9)
                        sim_tag = tag_prefix + '%03d' % prog_num
                        print sim_tag, current_sim_ident
                        current_sim_folder = scan_folder + '/' + current_sim_ident
                        os.mkdir(current_sim_folder)

                        rl.replaceline_and_save(
                            fname='secondary_emission_parameters.input',
                            findln='del_max =',
                            newline='del_max = %f\n' % del_max)

                        #~ rl.replaceline_and_save(fname = 'beam.beam',
                        #~ findln = 'sigmaz =', newline = 'sigmaz = %e\n'%sigmaz)

                        rl.replaceline_and_save(
                            fname='beam.beam',
                            findln='sigmaz =',
                            newline='sigmaz = %e/4.*299792458.\n' %
                            bl_4_sigma_s)

                        rl.replaceline_and_save(fname='beam.beam',
                                                findln='fact_beam =',
                                                newline='fact_beam = %e\n' %
                                                fact_beam)
from replaceline import replaceline_and_save
import sys

fname = sys.argv[1]
int_e11ppb = sys.argv[2]
replaceline_and_save(fname,
                     findln='intensity =',
                     newline=f'intensity = {int_e11ppb}e+11')