Add Explosive interfaces and restart

This commit is contained in:
Codex
2026-07-03 12:32:14 +08:00
parent 5853ac2644
commit 187af844d1
17 changed files with 629 additions and 32 deletions
+51
View File
@@ -120,6 +120,23 @@ class SPHLite:
]
self.lib.sphlite_get_gas_source_summary.restype = ctypes.c_int
self.lib.sphlite_set_ignition_point.argtypes = [
ctypes.c_double,
ctypes.c_double,
ctypes.c_double,
ctypes.c_double,
]
self.lib.sphlite_set_ignition_point.restype = ctypes.c_int
self.lib.sphlite_get_explosive_summary.argtypes = [
ctypes.POINTER(ctypes.c_int),
ctypes.POINTER(ctypes.c_int),
ctypes.POINTER(ctypes.c_double),
ctypes.POINTER(ctypes.c_double),
ctypes.POINTER(ctypes.c_double),
]
self.lib.sphlite_get_explosive_summary.restype = ctypes.c_int
self.lib.sphlite_get_particle_state.argtypes = [
ctypes.c_int,
ctypes.POINTER(ctypes.c_int),
@@ -384,6 +401,38 @@ class SPHLite:
"gas_source_energy": float(energy_source.value),
}
def set_ignition_point(self, x: float, y: float, z: float, time: float) -> None:
self._check(self.lib.sphlite_set_ignition_point(
float(x),
float(y),
float(z),
float(time),
))
def explosive_summary(self) -> dict[str, int | float | list[float]]:
particle_count = ctypes.c_int(0)
reacted_count = ctypes.c_int(0)
lambda_type = ctypes.c_double * 3
released_type = ctypes.c_double * 5
time_type = ctypes.c_double * 2
lambda_range = lambda_type()
released_totals = released_type()
detonation_range = time_type()
self._check(self.lib.sphlite_get_explosive_summary(
ctypes.byref(particle_count),
ctypes.byref(reacted_count),
lambda_range,
released_totals,
detonation_range,
))
return {
"explosive_particles": int(particle_count.value),
"explosive_reacted_particles": int(reacted_count.value),
"explosive_lambda_range": list(lambda_range),
"explosive_released_totals": list(released_totals),
"explosive_detonation_time_range": list(detonation_range),
}
def inspect(self, filename: str | Path) -> dict[str, int | float | list[float]]:
self.read_inp(filename)
self.build_model()
@@ -398,6 +447,7 @@ class SPHLite:
summary.update(self.gas_dt_limits())
summary.update(self.gas_extended_summary())
summary.update(self.gas_source_summary())
summary.update(self.explosive_summary())
return summary
def run(self, filename: str | Path) -> dict[str, int | float | list[float]]:
@@ -411,4 +461,5 @@ class SPHLite:
summary.update(self.gas_dt_limits())
summary.update(self.gas_extended_summary())
summary.update(self.gas_source_summary())
summary.update(self.explosive_summary())
return summary