def plot_surface(surface_name, cmap=None): """ Code used to plot a given surface """ surf = Surface() surf.load(surface_name) surf.plot(30, 30, cmap)
def simulation(tend, dt): """ starts the simulation, plots and writes the data creates a Surface Object and starts the simulation. the correct timestep is calculated with the timestep function from the advance module. Writes all calculated datapoints to a file with the filenname: basic_<tend>_<dt>.srf plots the simulation fpr t = 0 and t = tend :param tend: endtime of the simulation :param dt: timestep of the simulation """ s = Surface() time = 0 filename = f"basic_{tend}_{dt}.srf" s.plot(time) while time < tend: s.write(time, filename) advance(s, timestep(dt, time, tend)) time += timestep(dt, time, tend) s.write(time, filename) s.plot(time) plt.legend() plt.show()
def main(argv): sim_start_time = clock() # check if config is given as parameter if len(sys.argv) < 2: usage() exit() init_beam() cfg_file = sys.argv[1] srf_file = os.path.splitext(cfg_file)[0] + '.srf' par.LoadConfig(sys.argv[1]) init_sputtering() if par.INITIAL_SURFACE_FILE == 'False': dtime = par.TIME_STEP dt = dtime time = 0 end_time = par.TOTAL_TIME surface_start = Surface(par.XMAX, par.XMIN, par.DELTA_X, par.FUN_PEAK_TO_PEAK, par.TYPE, par.FUN_XMIN, par.FUN_XMAX, 0) surface = Surface(par.XMAX, par.XMIN, par.DELTA_X, par.FUN_PEAK_TO_PEAK, par.TYPE, par.FUN_XMIN, par.FUN_XMAX) #empty the file f = open(srf_file, 'w') f.close() surface.write(srf_file, time, surface_start.x.size, end_time, dtime) while time < end_time: advance( surface, dt, time ) #dtime is not needed -> par.TIME_STEP (not changing), current time is needed! surface.write(srf_file, time, surface.x.size, end_time, dtime) time, dt = timestep(dtime, time, end_time) surface.write(srf_file, time, surface_start.x.size, end_time, dtime) sim_end_time = clock() print("Execution time:" + str(sim_end_time - sim_start_time) + "s") if par.PLOT_SURFACE: surface_start.plot('OF Start', '-+r') surface.plot('OF Stop', '-+b') else: plot_cosine_cont()
def main(argv): sim_start_time = clock() # check if config is given as parameter if len(sys.argv) < 2: usage() exit() cfg_file = sys.argv[1] srf_file = os.path.splitext(cfg_file)[0] + '.srf' par.LoadConfig(sys.argv[1]) init_sputtering() dtime = par.TIME_STEP dt = dtime time = 0 end_time = par.TOTAL_TIME surface_start = Surface(par.XMAX, par.XMIN, par.DELTA_X) surface = Surface(par.XMAX, par.XMIN, par.DELTA_X) while time < end_time: advance(surface, dt) surface.write(srf_file, time, surface.x.size, end_time, dtime) time, dt = timestep(dtime, time, end_time) surface.write(srf_file, time, surface.x.size, end_time, dtime) sim_end_time = clock() print("Execution time:" + str(sim_end_time - sim_start_time) + "s") if par.PLOT_SURFACE: surface_start.plot('OF Start', '-+r') surface.plot('OF Stop','-+b')
import sys dir_path = os.getcwd() #Change path to where the beam module is located filepath = os.path.abspath(os.path.join(dir_path, "..", "..", "code")) #use the above path to futher import the beam_flux fnc sys.path.append(filepath) from beam import beam_flux import parameters as par from surface import Surface par.LoadConfig('gauss.cfg') xmax = par.XMAX xmin = par.XMIN step = par.DELTA_X x = np.arange(xmin, (xmax + 1), step) fb = beam_flux(x) const = np.full_like(x, par.BEAM_CURRENT_DENSITY / elementary_charge) s = Surface() s.plot('OF Stop', 'b+-') """ par.LoadConfig('erf.cfg') fb2 = beam_flux(x) plt.plot(x,fb2) plt.plot(x,fb) plt.plot(x,const)"""
import parameters as par import time import matplotlib.pyplot as plt config_filename = "yamamura.cfg" config_file = os.path.join(os.path.dirname(__file__), config_filename) if not config_file.endswith('.cfg'): print('Error: Incorrect config.') sys.exit() filename = os.path.splitext(config_file)[0] + '.srf' if os.path.exists(filename): os.remove(filename) par.load_parameters(config_file) # my stuff (Claus Spitzer 11816266) my_surface = Surface() my_surface.plot(10) # 10 ist nur ein Dummy my_surface.write(10, filename) start = time.time() my_surface.view_factor() stop = time.time() print('Computation time for view_factor: ', (stop - start) * 1000, 'ms') # plt.show()