Loading 6_precrack_density_refernce/fs_strength 0 → 100755 +73.1 KiB File added.No diff preview for this file type. View file 6_precrack_density_refernce/parse_iv_data.py 0 → 100644 +45 −0 Original line number Diff line number Diff line import mechnet as mn import numpy as np import matplotlib.pyplot as plt import h5py import sys sys.path.append("/home/lpyka/hierarchical_interface") from lib.push_data import push_data_to, push_ivcat def get_iv_data(filepath): grouppaths = mn.datman.bundle_all_sub_groups(filepath, ["simulationdata"]) simdata = mn.datman.get_simdata(filepath, grouppaths[0], readpickled=False) simdata_dict = simdata.get_simdata_dict() iv_data = np.array(simdata_dict["logged_data"]["iv"]) return iv_data def plot_iv_curve(data): fig, ax = plt.subplots() x = data[:,1] y = data[:,0] ax.plot(x, y) plt.show() def append_data_to_txt(data, seed): with open("ivcat.txt", 'a') as file: file.write(f"#seed_{seed}\n") for point in data: x, y = point file.write(f"{x} {y}\n") def clear_txt_file(): with open("ivcat.txt", "w") as f: f.write("") if __name__ == "__main__": offset = input("Offset: ") base_path = f"/FASTTEMP/p7/lpyka/hierarchical_interface/2_offset_hierarchical_struct/offset_{offset}" clear_txt_file() for seed in range(1000,1050): file_name = f"FDB_PARSOL_SIRC-FCVC_SOG-IVCG_HFBA_CPC-NIC_-_{seed}.h5" full_path = base_path + "/" + file_name iv_data = get_iv_data(full_path) #plot_iv_curve(iv_data) append_data_to_txt(iv_data, seed) push_ivcat(base_path) print("cutoff prev") No newline at end of file 6_precrack_density_refernce/precracked_density_offset.py 0 → 100644 +89 −0 Original line number Diff line number Diff line import sys import numpy as np import mechnet as mn from multiprocessing import Pool from functools import partial sys.path.append("/home/lpyka/hierarchical_interface/") from lib.push_data import push_data_to, copy_runfile_to from lib.my_plot_edges import plot_edges_mechnet_network def get_parametercollection(seed,crack_length, offset): par = mn.ParameterCollection() nx = 128 # needs to == el**h ny = nx nz = 9 + offset # need to be >= h +2 + o_set (+2 bc bound cond) n = nx*ny*nz par.set_N(n) par.set_Nx(nx) par.set_Ny(ny) par.set_Nz(nz) par.set_NxNy() #set precracks x_start=0, x_end=crack_length, y_start = 0, y_end=ny par.set_listofhorizontalprecracks([[0,crack_length, 0, ny-1, offset]]) #new parameters necessary for the structure par.set_xhierarchicalelementsize(2) # log_el(nx) = h <-> nx = el**h par.set_yhierarchicalelementsize(2) par.set_gapzoffset(offset) # == o_set par.set_thresholdrng(seed) par.set_structurerng(seed + 1_000_000) par.set_weibullparameter(4) par.set_scalingfactor(1.00) par.set_uniformupperdirichlet(1.0) return par def run_a_simulation_fuse(seed, crack_length, offset): constructor = mn.cubic3D.Cubic3DFullConnectionConstructor() #new decorators to modify network structure: #random positioning of missing edges fitting to the amount that would be missing in a hierarchical network with #element sizes as determined by set_xhierarchicalelementsize() and set_yhierarchicalelementsize() #in the corresponding directions; arangement dependent on seed given by set_structurerng() #for the random positioning constructor = mn.cubic3D.DensityReferenceOffsetDecorator(constructor) constructor = mn.cubic3D.InitialHorizontalPrecracksDecorator(constructor) constructor = mn.cubic3D.ScalingWeibullThresholdDecorator(constructor) boundaries = mn.general.EmptyBoundariesConstructor() boundaries = mn.cubic3D.FixedLowerBoundaryDecorator(boundaries) boundaries = mn.cubic3D.UniformDisplacedUpperBoundaryDecorator(boundaries) parametercollection = get_parametercollection(seed,crack_length=crack_length, offset=offset) network = constructor.start_construction(parametercollection) bounded_network = boundaries.start_assign_boundaries(network) #switch to fuse simulation to make it easier to read the resulting stiffness matrix dict_of_simulation_parameters = {"niter":10_000_000, "externalV":1.0, "accuracy":12} builder = mn.sim.FuseDirichletBuilder() solver = mn.sim.PARDISOBindingsSolver() intrescal = mn.sim.StartInterimResultsCalculator() #InterimResultsCalculator stack pre-computes data needed for output and simulation step intrescal = mn.sim.FuseCurrentsVoltagesCalculator(intrescal) outgen = mn.sim.StartOutputGenerator() outgen = mn.sim.IVCurveGenerator(outgen) applier = mn.sim.HottestFuseBreakApplier() checker = mn.sim.NonInitialChecker(mn.sim.ConnectedPathChecker()) simulation = mn.sim.Simulation(builder, solver, intrescal, outgen, applier, checker) dict_of_crs_edge_data = bounded_network.get_network_data() simdata = simulation.start_simulation(dict_of_crs_edge_data, dict_of_simulation_parameters) simdata_dict = simdata.get_simdata_dict() network_descriptor_dict = bounded_network.get_construction_data() mn.datman.save_simulation_output(network_descriptor_dict, simdata_dict, simulation.simulationname, simulation.simulationdoc, suffix=str(seed), overwritemode = False) print("done with sim of seed", seed) return (network_descriptor_dict, simdata_dict, simulation.simulationname, simulation.simulationdoc) if __name__=="__main__": list_of_seeds = [] offset = 5 crack_lengths = [10, 20, 30, 40, 50] for crack_length in crack_lengths: for seed in range(1000, 1010): list_of_seeds.append(seed) with Pool(10) as p: results = p.map(partial(run_a_simulation_fuse, crack_length=crack_length, offset=offset), list_of_seeds) # for data in results: # mn.datman.save_simulation_output(data[0], data[1], data[2], data[3], targetdirectory="./", suffix="", overwritemode=False) #print(data[1]["current_data"]["stiffnessmatrix"].toarray()) destination = f"/FASTTEMP/p7/lpyka/hierarchical_interface/6_precrack_density_offset/a_{crack_length}" push_data_to(destination) copy_runfile_to(runfile_name=__file__, destination=destination) print(f"done with crack_lenght {crack_length}") print("\nRun successfull.") Loading
6_precrack_density_refernce/fs_strength 0 → 100755 +73.1 KiB File added.No diff preview for this file type. View file
6_precrack_density_refernce/parse_iv_data.py 0 → 100644 +45 −0 Original line number Diff line number Diff line import mechnet as mn import numpy as np import matplotlib.pyplot as plt import h5py import sys sys.path.append("/home/lpyka/hierarchical_interface") from lib.push_data import push_data_to, push_ivcat def get_iv_data(filepath): grouppaths = mn.datman.bundle_all_sub_groups(filepath, ["simulationdata"]) simdata = mn.datman.get_simdata(filepath, grouppaths[0], readpickled=False) simdata_dict = simdata.get_simdata_dict() iv_data = np.array(simdata_dict["logged_data"]["iv"]) return iv_data def plot_iv_curve(data): fig, ax = plt.subplots() x = data[:,1] y = data[:,0] ax.plot(x, y) plt.show() def append_data_to_txt(data, seed): with open("ivcat.txt", 'a') as file: file.write(f"#seed_{seed}\n") for point in data: x, y = point file.write(f"{x} {y}\n") def clear_txt_file(): with open("ivcat.txt", "w") as f: f.write("") if __name__ == "__main__": offset = input("Offset: ") base_path = f"/FASTTEMP/p7/lpyka/hierarchical_interface/2_offset_hierarchical_struct/offset_{offset}" clear_txt_file() for seed in range(1000,1050): file_name = f"FDB_PARSOL_SIRC-FCVC_SOG-IVCG_HFBA_CPC-NIC_-_{seed}.h5" full_path = base_path + "/" + file_name iv_data = get_iv_data(full_path) #plot_iv_curve(iv_data) append_data_to_txt(iv_data, seed) push_ivcat(base_path) print("cutoff prev") No newline at end of file
6_precrack_density_refernce/precracked_density_offset.py 0 → 100644 +89 −0 Original line number Diff line number Diff line import sys import numpy as np import mechnet as mn from multiprocessing import Pool from functools import partial sys.path.append("/home/lpyka/hierarchical_interface/") from lib.push_data import push_data_to, copy_runfile_to from lib.my_plot_edges import plot_edges_mechnet_network def get_parametercollection(seed,crack_length, offset): par = mn.ParameterCollection() nx = 128 # needs to == el**h ny = nx nz = 9 + offset # need to be >= h +2 + o_set (+2 bc bound cond) n = nx*ny*nz par.set_N(n) par.set_Nx(nx) par.set_Ny(ny) par.set_Nz(nz) par.set_NxNy() #set precracks x_start=0, x_end=crack_length, y_start = 0, y_end=ny par.set_listofhorizontalprecracks([[0,crack_length, 0, ny-1, offset]]) #new parameters necessary for the structure par.set_xhierarchicalelementsize(2) # log_el(nx) = h <-> nx = el**h par.set_yhierarchicalelementsize(2) par.set_gapzoffset(offset) # == o_set par.set_thresholdrng(seed) par.set_structurerng(seed + 1_000_000) par.set_weibullparameter(4) par.set_scalingfactor(1.00) par.set_uniformupperdirichlet(1.0) return par def run_a_simulation_fuse(seed, crack_length, offset): constructor = mn.cubic3D.Cubic3DFullConnectionConstructor() #new decorators to modify network structure: #random positioning of missing edges fitting to the amount that would be missing in a hierarchical network with #element sizes as determined by set_xhierarchicalelementsize() and set_yhierarchicalelementsize() #in the corresponding directions; arangement dependent on seed given by set_structurerng() #for the random positioning constructor = mn.cubic3D.DensityReferenceOffsetDecorator(constructor) constructor = mn.cubic3D.InitialHorizontalPrecracksDecorator(constructor) constructor = mn.cubic3D.ScalingWeibullThresholdDecorator(constructor) boundaries = mn.general.EmptyBoundariesConstructor() boundaries = mn.cubic3D.FixedLowerBoundaryDecorator(boundaries) boundaries = mn.cubic3D.UniformDisplacedUpperBoundaryDecorator(boundaries) parametercollection = get_parametercollection(seed,crack_length=crack_length, offset=offset) network = constructor.start_construction(parametercollection) bounded_network = boundaries.start_assign_boundaries(network) #switch to fuse simulation to make it easier to read the resulting stiffness matrix dict_of_simulation_parameters = {"niter":10_000_000, "externalV":1.0, "accuracy":12} builder = mn.sim.FuseDirichletBuilder() solver = mn.sim.PARDISOBindingsSolver() intrescal = mn.sim.StartInterimResultsCalculator() #InterimResultsCalculator stack pre-computes data needed for output and simulation step intrescal = mn.sim.FuseCurrentsVoltagesCalculator(intrescal) outgen = mn.sim.StartOutputGenerator() outgen = mn.sim.IVCurveGenerator(outgen) applier = mn.sim.HottestFuseBreakApplier() checker = mn.sim.NonInitialChecker(mn.sim.ConnectedPathChecker()) simulation = mn.sim.Simulation(builder, solver, intrescal, outgen, applier, checker) dict_of_crs_edge_data = bounded_network.get_network_data() simdata = simulation.start_simulation(dict_of_crs_edge_data, dict_of_simulation_parameters) simdata_dict = simdata.get_simdata_dict() network_descriptor_dict = bounded_network.get_construction_data() mn.datman.save_simulation_output(network_descriptor_dict, simdata_dict, simulation.simulationname, simulation.simulationdoc, suffix=str(seed), overwritemode = False) print("done with sim of seed", seed) return (network_descriptor_dict, simdata_dict, simulation.simulationname, simulation.simulationdoc) if __name__=="__main__": list_of_seeds = [] offset = 5 crack_lengths = [10, 20, 30, 40, 50] for crack_length in crack_lengths: for seed in range(1000, 1010): list_of_seeds.append(seed) with Pool(10) as p: results = p.map(partial(run_a_simulation_fuse, crack_length=crack_length, offset=offset), list_of_seeds) # for data in results: # mn.datman.save_simulation_output(data[0], data[1], data[2], data[3], targetdirectory="./", suffix="", overwritemode=False) #print(data[1]["current_data"]["stiffnessmatrix"].toarray()) destination = f"/FASTTEMP/p7/lpyka/hierarchical_interface/6_precrack_density_offset/a_{crack_length}" push_data_to(destination) copy_runfile_to(runfile_name=__file__, destination=destination) print(f"done with crack_lenght {crack_length}") print("\nRun successfull.")