def setup_method(self, method): policy_set = {"plen": 12, "psets": 4, "pdict": 1, "phist": 3, "prenew": 3, "pattempts": 1, "pautorecover": 0} self.multi_policy = simulation() self.multi_policy.set_multi_policy(policy_set) self.policy = simulation() self.policy.set_policy("plen", 12) self.policy.set_policy("psets", 4) self.policy.set_policy("pdict", 1) self.policy.set_policy("phist", 3) self.policy.set_policy("prenew", 3) self.policy.set_policy("pattempts", 1) self.policy.set_policy("pautorecover", 0)
def setup_method(self, method): self.policy = simulation() self.policy.set_policy("plen", 12) self.policy.set_policy("psets", 4) self.policy.set_policy("pdict", 1) self.policy.set_policy("phist", 3) self.policy.set_policy("prenew", 3) self.policy.set_policy("pattempts", 1) self.policy.set_policy("pautorecover", 0)
# initial conditions position_start = sim.vector( 0, 0 ) # initial position (need to be >0) velocity_start = sim.vector( 10, 100 ) # initial velocity velocity_wind= sim.vector( -100, 0 ) # wind velocity g = sim.vector( 0, -98.0665 ) # gravitation force cross_section_area = 6*0.001 # cross section area drag_coefficient = 0.45 # drag coefficient mass = 0.05 # bullet mass fluid_density = 0.1 # air density dt = 0.01 # time step # simulation bullet = sim.bullet( mass, position_start, velocity_start, cross_section_area * drag_coefficient ) cond = sim.external( fluid_density, velocity_wind, g ) s = sim.simulation(bullet, cond, dt) xx , yy = s.read_out() # plotting fig, ax = plt.subplots() line, = ax.plot([], [], lw=2) ax.set_ylim(0, 100) ax.set_xlim(-100, 100) ax.grid() xdata, ydata = [], [] t_max = len( xx ) t=-1 def run(argument): global t
B_val = str('B=')+str(B) # Run through the files for suffix in filt: # Print the intentions of the script to keep track of code's location print(str('Changing the directory to:')+str(' simulations/workingsims_psf/')+str(B_val)+str('/')+str(suffix)+str('/background_15K/\n')) # Change the directory to the directory housing the band data os.chdir('simulations/workingsims_psf/'+str(B_val)+str('/')+str(suffix)+str('/background_15K/')) # Print to tell simulation is being run print(str('Now running the simulation for ')+str(suffix)+str('\n')) # Run the simulation itself sim_data = simulation(mode=mode ,filt=str(suffix), npix=npix, sizeau=sizeau, d=d, mass=mass, cloud_density=cloud_density, outside_density=outside_density, cloud_temp=cloud_temp, outside_temp=outside_temp, kappa_0=kappa_0, lambda_0=lambda_0, B=B, amr=amr, dust=dust) # Print to tell simulation is being run print(str('Now determining the SED for')+str(suffix)+str('\n')) # Determine the limit to filter for min_val = np.amin(sim_data) max_val = np.amax(sim_data) std_val = np.std(sim_data) # Determine the SED sedGeneration(filt=str(suffix), sim_name='cloud', kappa_0=kappa_0, lambda_0=lambda_0, B=B, withPSF=True) # Change the directory back to the folder containing this file os.chdir('../../../../../')
import os import sys import random from math import log import matplotlib.pyplot as plt from sim import Color, semaphore from sim import Sim as simulation from sim import queue simulation_time = 3600 simul = simulation(simulation_time) car_queue = queue() man_queue = queue() def exp_generator(mean): return -log(1 - random.random()) * mean class semaphore_w_button(): def __init__(self): self.button_active = True self.car_sem = semaphore(start_color=Color.RED) self.people_sem = semaphore(start_color=Color.RED) self.press_button_event = None self.change_state_time = 0