Commit ee8a51af authored by Leon Pyka's avatar Leon Pyka
Browse files

generating IV curve

parent c5d69f3a
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -2,12 +2,15 @@ import sys
import numpy as np
import mechnet as mn
from multiprocessing import Pool
from functools import partial
sys.path.append(".")
from lib.push_data import push_data_to 

def get_parametercollection(seed):
def get_parametercollection(seed, offset):
    par = mn.ParameterCollection()
    nx = 64 # needs to == el**h
    nx = 8 # needs to == el**h
    ny = nx
    nz = 9 # need to be >=  h +2 + o_set (+2 bc bound cond)    
    nz = 5 + offset # need to be >=  h +2 + o_set (+2 bc bound cond)    
    n = nx*ny*nz
    par.set_N(n)
    par.set_Nx(nx)
@@ -17,7 +20,7 @@ def get_parametercollection(seed):
    #new parameters necessary for the structure
    par.set_xhierarchicalelementsize(2) # log_el(nx) = h <-> nx = el**h 
    par.set_yhierarchicalelementsize(2)
    par.set_gapzoffset(1) # == o_set
    par.set_gapzoffset(offset) # == o_set
    par.set_thresholdrng(seed)
    par.set_structurerng(seed + 1_000_000)
    par.set_weibullparameter(1.5)
@@ -25,7 +28,7 @@ def get_parametercollection(seed):
    par.set_uniformupperdirichlet(1.0)
    return par

def run_a_simulation_fuse(seed):
def run_a_simulation_fuse(seed, 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
@@ -39,7 +42,7 @@ def run_a_simulation_fuse(seed):
    boundaries = mn.cubic3D.FixedLowerBoundaryDecorator(boundaries)
    boundaries = mn.cubic3D.UniformDisplacedUpperBoundaryDecorator(boundaries)
    
    parametercollection = get_parametercollection(seed)
    parametercollection = get_parametercollection(seed, offset)
    network = constructor.start_construction(parametercollection)
    bounded_network = boundaries.start_assign_boundaries(network)

@@ -50,6 +53,7 @@ def run_a_simulation_fuse(seed):
    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)
@@ -64,12 +68,14 @@ def run_a_simulation_fuse(seed):
    return (network_descriptor_dict, simdata_dict, simulation.simulationname, simulation.simulationdoc)

if __name__=="__main__":
    list_of_parameters =  []
    list_of_seeds =  []
    offset = 1
    for seed in range(1000, 1010):
        list_of_parameters.append(seed) 
        list_of_seeds.append(seed) 
    with Pool(10) as p:
        results = p.map(run_a_simulation_fuse, list_of_parameters)
        results = p.map(partial(run_a_simulation_fuse, 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())
    push_data_to(f"/FASTTEMP/p7/lpyka/hierarchical_interface/2_offset_hierarchical_struct/offset_{offset}")
    print("\nRun successfull.")
 No newline at end of file
+0 −74
Original line number Diff line number Diff line
import sys
import numpy as np
import mechnet as mn
from multiprocessing import Pool

def get_parametercollection(seed):
    par = mn.ParameterCollection()
    nx = 64 # needs to == el**h
    ny = nx
    nz = 8 # 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()
    #new parameters necessary for the structure
    par.set_xhierarchicalelementsize(2) # log_el(nx) = h <-> nx = el**h 
    par.set_yhierarchicalelementsize(2)
    par.set_thresholdrng(seed)
    par.set_structurerng(seed + 1_000_000)
    par.set_weibullparameter(1.5)
    par.set_scalingfactor(1.00)
    par.set_uniformupperdirichlet(1.0)
    return par

def run_a_simulation_fuse(seed):
    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.ShuffledHierarchicalGapsDecorator(constructor)
    constructor = mn.cubic3D.ScalingWeibullThresholdDecorator(constructor)

    boundaries = mn.general.EmptyBoundariesConstructor()
    boundaries = mn.cubic3D.FixedLowerBoundaryDecorator(boundaries)
    boundaries = mn.cubic3D.UniformDisplacedUpperBoundaryDecorator(boundaries)
    
    parametercollection = get_parametercollection(seed)
    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()
    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_parameters =  []
    for seed in range(1000, 1010):
        list_of_parameters.append(seed) 
    with Pool(10) as p:
        results = p.map(run_a_simulation_fuse, list_of_parameters)
 #   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())
    print("\nRun successfull.")
 No newline at end of file
+0 −74
Original line number Diff line number Diff line
import sys
import numpy as np
import mechnet as mn
from multiprocessing import Pool

def get_parametercollection(seed):
    par = mn.ParameterCollection()
    nx = 64 # needs to == el**h
    ny = nx
    nz = 9 # 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()
    #new parameters necessary for the structure
    par.set_xhierarchicalelementsize(2) # log_el(nx) = h <-> nx = el**h 
    par.set_yhierarchicalelementsize(2)
    par.set_gapzoffset(1) # == o_set
    par.set_thresholdrng(seed)
    par.set_structurerng(seed + 1_000_000)
    par.set_weibullparameter(1.5)
    par.set_scalingfactor(1.00)
    par.set_uniformupperdirichlet(1.0)
    return par

def run_a_simulation_fuse(seed):
    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.ShuffledHierarchicalOffsetDecorator(constructor)
    constructor = mn.cubic3D.ScalingWeibullThresholdDecorator(constructor)

    boundaries = mn.general.EmptyBoundariesConstructor()
    boundaries = mn.cubic3D.FixedLowerBoundaryDecorator(boundaries)
    boundaries = mn.cubic3D.UniformDisplacedUpperBoundaryDecorator(boundaries)
    
    parametercollection = get_parametercollection(seed)
    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()
    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()
    print("done with sim of seed", seed)
    return (network_descriptor_dict, simdata_dict, simulation.simulationname, simulation.simulationdoc)

if __name__=="__main__":
    list_of_parameters =  []
    for seed in range(1000, 1010):
        list_of_parameters.append(seed) 
    with Pool(10) as p:
        results = p.map(run_a_simulation_fuse, list_of_parameters)
    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())
    print("\nRun successfull.")
 No newline at end of file
−17.5 KiB
Loading image diff...
+0 −74
Original line number Diff line number Diff line
import sys
import numpy as np
import mechnet as mn
from multiprocessing import Pool

def get_parametercollection(seed):
    par = mn.ParameterCollection()
    nx = 64 # needs to == el**h
    ny = nx
    nz = 18 # 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()
    #new parameters necessary for the structure
    par.set_xhierarchicalelementsize(2) # log_el(nx) = h <-> nx = el**h 
    par.set_yhierarchicalelementsize(2)
    par.set_gapzoffset(10) # == o_set
    par.set_thresholdrng(seed)
    par.set_structurerng(seed + 1_000_000)
    par.set_weibullparameter(1.5)
    par.set_scalingfactor(1.00)
    par.set_uniformupperdirichlet(1.0)
    return par

def run_a_simulation_fuse(seed):
    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.ShuffledHierarchicalOffsetDecorator(constructor)
    constructor = mn.cubic3D.ScalingWeibullThresholdDecorator(constructor)

    boundaries = mn.general.EmptyBoundariesConstructor()
    boundaries = mn.cubic3D.FixedLowerBoundaryDecorator(boundaries)
    boundaries = mn.cubic3D.UniformDisplacedUpperBoundaryDecorator(boundaries)
    
    parametercollection = get_parametercollection(seed)
    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()
    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()
    print("done with sim of seed", seed)
    return (network_descriptor_dict, simdata_dict, simulation.simulationname, simulation.simulationdoc)

if __name__=="__main__":
    list_of_parameters =  []
    for seed in range(1000, 1010):
        list_of_parameters.append(seed) 
    with Pool(10) as p:
        results = p.map(run_a_simulation_fuse, list_of_parameters)
    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())
    print("\nRun successfull.")
 No newline at end of file
Loading