Fri 16 May 23:06:54 CEST 2025
This commit is contained in:
parent
eab3d82653
commit
3e6dc85208
|
@ -24,7 +24,7 @@ from SimNDT.core.materialLibrary import getMaterialLibrary
|
|||
|
||||
|
||||
|
||||
def read_scenario(sim_params, SimNDT_geom_objects, SimNDT_Bc_objs):
|
||||
def read_scenario(sim_params, SimNDT_geom_objects, SimNDT_Bc_objs, SimNDT_Mat_objs):
|
||||
"""
|
||||
Reads and sets up the scenario based on the provided simulation parameters, geometric objects, and boundary conditions.
|
||||
|
||||
|
@ -71,9 +71,9 @@ def read_geometry_objects(sim_params):
|
|||
"""
|
||||
# geometric objects
|
||||
# geometric objects
|
||||
SimNDT_geom_objects = []
|
||||
if "GeometricObjects" in sim_params.keys():
|
||||
print("Showing {} GeometricObjects.".format(len(sim_params["GeometricObjects"])))
|
||||
SimNDT_geom_objects = []
|
||||
for geom_num in range(len(sim_params["GeometricObjects"])):
|
||||
geom_name = sim_params["GeometricObjects"][geom_num]["Name"]
|
||||
|
||||
|
@ -608,7 +608,35 @@ def checkSimulation(Scenario, Materials, Boundaries, Transducers, Inspection, Si
|
|||
# If no valueerror is raised, then the simulation is ready to run
|
||||
print("Simulation is ready to run!!!")
|
||||
|
||||
def enableSnapshot(sim_params):
|
||||
def read_import(sim_params,SimNDT_Scenario,SimNDT_Simulation):
|
||||
print("Searching Import section...")
|
||||
importIm = 0
|
||||
importIabs = 0
|
||||
importI = 0
|
||||
if "Import" in sim_params.keys():
|
||||
print("Found Import section.")
|
||||
if "I" in sim_params["Import"].keys():
|
||||
importI = sim_params["Import"]["I"]
|
||||
if "Iabs" in sim_params["Import"].keys():
|
||||
importIabs = sim_params["Import"]["Iabs"]
|
||||
if "Im" in sim_params["Import"].keys():
|
||||
importIm = sim_params["Import"]["Im"]
|
||||
if "Rho" in sim_params["Import"].keys():
|
||||
# must be imported later by the efit2d engine ...
|
||||
SimNDT_Simulation.importRho = sim_params["Import"]["Rho"]
|
||||
if "VT" in sim_params["Import"].keys():
|
||||
# must be imported later by the efit2d engine ...
|
||||
SimNDT_Simulation.importVT = sim_params["Import"]["VT"]
|
||||
if "VL" in sim_params["Import"].keys():
|
||||
# must be imported later by the efit2d engine ...
|
||||
SimNDT_Simulation.importVL = sim_params["Import"]["VL"]
|
||||
if importIm:
|
||||
print("Reading Im from "+importIm)
|
||||
importIm = np.load(importIm)
|
||||
print (np.shape(importIm))
|
||||
SimNDT_Simulation.update_numericalModel(SimNDT_Scenario,importIm,0)
|
||||
|
||||
def read_export(sim_params):
|
||||
"""
|
||||
Enables and sets up snapshots for the simulation, including properties like step size, file path, and fields to save.
|
||||
|
||||
|
@ -618,25 +646,69 @@ def enableSnapshot(sim_params):
|
|||
Returns:
|
||||
- SimNDT_SnapShots: The snapshots object.
|
||||
"""
|
||||
print("Searching Export (Snapshot) section...")
|
||||
if "Snapshot" in sim_params.keys():
|
||||
step = sim_params["Snapshot"]["Step"]
|
||||
save_filepath = sim_params["Snapshot"]["Save_filepath"]
|
||||
filename = sim_params["Snapshot"]["Filename"]
|
||||
enableFields = sim_params["Snapshot"]["enableFields"]
|
||||
enableNumPy = sim_params["Snapshot"]["enableNumPy"]
|
||||
extension = sim_params["Snapshot"]["Extension"]
|
||||
db = sim_params["Snapshot"]["dB"]
|
||||
color = sim_params["Snapshot"]["Color"]
|
||||
field = sim_params["Snapshot"]["Field"]
|
||||
enableSignals = sim_params["Snapshot"]["enableSignals"]
|
||||
enableImages = sim_params["Snapshot"]["enableImages"]
|
||||
enableVolume = sim_params["Snapshot"]["enableVolume"]
|
||||
enableView = sim_params["Snapshot"]["enableView"]
|
||||
sensorShape = sim_params["Snapshot"]["sensorShape"]
|
||||
sensorPlacement = sim_params["Snapshot"]["sensorPlacement"]
|
||||
sensorSize = sim_params["Snapshot"]["sensorSize"]
|
||||
|
||||
print("Steps for Snapshots="+str(step))
|
||||
sim_params["Export"]["Export"] = sim_params["Export"]["Snapshot"]
|
||||
if "Export" in sim_params.keys():
|
||||
print("Found Export section.")
|
||||
step = sim_params["Export"]["Step"]
|
||||
save_filepath = sim_params["Export"]["Save_filepath"]
|
||||
filename = sim_params["Export"]["Filename"]
|
||||
if "enableFields" in sim_params["Export"].keys():
|
||||
enableFields = sim_params["Export"]["enableFields"]
|
||||
else:
|
||||
enableFields = False
|
||||
if "enableNumPy" in sim_params["Export"].keys():
|
||||
enableNumPy = sim_params["Export"]["enableNumPy"]
|
||||
else:
|
||||
enableNumPy = True
|
||||
extension = sim_params["Export"]["Extension"]
|
||||
if "dB" in sim_params["Export"].keys():
|
||||
db = sim_params["Export"]["dB"]
|
||||
else:
|
||||
db = 50
|
||||
if "Color" in sim_params["Export"].keys():
|
||||
color = sim_params["Export"]["Color"]
|
||||
else:
|
||||
color = 0
|
||||
field = sim_params["Export"]["Field"]
|
||||
if "Material" in sim_params["Export"].keys():
|
||||
material = sim_params["Export"]["Material"]
|
||||
else:
|
||||
material = 0
|
||||
if "enableSignals" in sim_params["Export"].keys():
|
||||
enableSignals = sim_params["Export"]["enableSignals"]
|
||||
else:
|
||||
enableSignals = False
|
||||
if "enableImages" in sim_params["Export"].keys():
|
||||
enableImages = sim_params["Export"]["enableImages"]
|
||||
else:
|
||||
enableImages = False
|
||||
if "enableMaterial" in sim_params["Export"].keys():
|
||||
enableMaterial = sim_params["Export"]["enableMaterial"]
|
||||
else:
|
||||
enableMaterial = False
|
||||
if "enableVolume" in sim_params["Export"].keys():
|
||||
enableVolume = sim_params["Export"]["enableVolume"]
|
||||
else:
|
||||
enableVolume = False
|
||||
if "enableView" in sim_params["Export"].keys():
|
||||
enableView = sim_params["Export"]["enableView"]
|
||||
else:
|
||||
enableView = False
|
||||
if "sensorShape" in sim_params["Export"].keys():
|
||||
sensorShape = sim_params["Export"]["sensorShape"]
|
||||
else:
|
||||
sensorShape = []
|
||||
if "sensorPlacement" in sim_params["Export"].keys():
|
||||
sensorPlacement = sim_params["Export"]["sensorPlacement"]
|
||||
else:
|
||||
sensorPlacement = []
|
||||
if "sensorSize" in sim_params["Export"].keys():
|
||||
sensorSize = sim_params["Export"]["sensorSize"]
|
||||
else:
|
||||
sensorSize = 0
|
||||
print("Steps for Export="+str(step))
|
||||
# RunSimulation(self.filename, self.SimNDT_Simulation)
|
||||
SimNDT_SnapShots = SnapShots(
|
||||
Enable=True,
|
||||
|
@ -649,8 +721,10 @@ def enableSnapshot(sim_params):
|
|||
dB=db,
|
||||
Color=color,
|
||||
Field=field,
|
||||
Material=material,
|
||||
enableSignals=enableSignals,
|
||||
enableImages=enableImages,
|
||||
enableMaterial=enableMaterial,
|
||||
enableVolume=enableVolume,
|
||||
enableView=enableView,
|
||||
sensorShape=sensorShape,
|
||||
|
@ -658,6 +732,8 @@ def enableSnapshot(sim_params):
|
|||
sensorSize=sensorSize
|
||||
)
|
||||
return SimNDT_SnapShots
|
||||
else:
|
||||
print ("No Export/Snapshot section found. Fatal.")
|
||||
|
||||
|
||||
def openSim(sim_params):
|
||||
|
@ -699,7 +775,7 @@ def openSim(sim_params):
|
|||
SimNDT_geom_objects = read_geometry_objects(sim_params)
|
||||
SimNDT_Mat_objs = read_materials(sim_params,SimNDT_Library)
|
||||
SimNDT_Bc_objs = read_boundaries(sim_params)
|
||||
SimNDT_Scenario = read_scenario(sim_params, SimNDT_geom_objects, SimNDT_Bc_objs)
|
||||
SimNDT_Scenario = read_scenario(sim_params, SimNDT_geom_objects, SimNDT_Bc_objs, SimNDT_Mat_objs)
|
||||
|
||||
SimNDT_Source = read_source(sim_params)
|
||||
SimNDT_Signal = read_signal(sim_params)
|
||||
|
@ -713,6 +789,7 @@ def openSim(sim_params):
|
|||
SingleLaunchSetup(SimNDT_Scenario, SimNDT_Source, SimNDT_Inspection, SimNDT_Transd_objs, SimNDT_Signal)
|
||||
|
||||
SimNDT_Simulation = read_simulation(sim_params)
|
||||
|
||||
# sets up simulation env
|
||||
SimulationSetup(SimNDT_Scenario, SimNDT_Mat_objs, SimNDT_Transd_objs, SimNDT_Simulation)
|
||||
# checking labels, setting inspection and fixing boundary if necessary
|
||||
|
@ -721,7 +798,9 @@ def openSim(sim_params):
|
|||
|
||||
SimNDT_Receivers = read_receivers(sim_params)
|
||||
|
||||
SimNDT_SnapShots = enableSnapshot(sim_params)
|
||||
read_import(sim_params,SimNDT_Scenario,SimNDT_Simulation)
|
||||
|
||||
SimNDT_SnapShots = read_export(sim_params)
|
||||
|
||||
print("steps: ", SimNDT_SnapShots.Step)
|
||||
print("Finished reading all parameters.")
|
||||
|
@ -754,11 +833,9 @@ def runEngine(simPack):
|
|||
- SimNDT_SnapShots: The snapshots object.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
engine = EngineController(simPack, simPack.SnapShots)
|
||||
|
||||
|
||||
simPack.SimNDT_Engine = engine
|
||||
|
||||
state = engine.run()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user