Extend Gas restart and interfaces

This commit is contained in:
Codex
2026-07-03 11:04:59 +08:00
parent c834006eaf
commit 4203170bea
16 changed files with 620 additions and 31 deletions
+56
View File
@@ -105,6 +105,21 @@ class SPHLite:
]
self.lib.sphlite_get_gas_dt_limits.restype = ctypes.c_int
self.lib.sphlite_get_gas_extended_summary.argtypes = [
ctypes.POINTER(ctypes.c_double),
ctypes.POINTER(ctypes.c_double),
ctypes.POINTER(ctypes.c_double),
ctypes.POINTER(ctypes.c_double),
]
self.lib.sphlite_get_gas_extended_summary.restype = ctypes.c_int
self.lib.sphlite_get_gas_source_summary.argtypes = [
ctypes.POINTER(ctypes.c_double),
ctypes.POINTER(ctypes.c_double),
ctypes.POINTER(ctypes.c_double),
]
self.lib.sphlite_get_gas_source_summary.restype = ctypes.c_int
self.lib.sphlite_get_particle_state.argtypes = [
ctypes.c_int,
ctypes.POINTER(ctypes.c_int),
@@ -332,6 +347,43 @@ class SPHLite:
"gas_dtcrit": float(dtcrit.value),
}
def gas_extended_summary(self) -> dict[str, float | list[float]]:
mass = ctypes.c_double(0.0)
momentum_type = ctypes.c_double * 3
range_type = ctypes.c_double * 2
limits_type = ctypes.c_double * 3
momentum = momentum_type()
density_range = range_type()
dt_limits = limits_type()
self._check(self.lib.sphlite_get_gas_extended_summary(
ctypes.byref(mass),
momentum,
density_range,
dt_limits,
))
return {
"gas_mass": float(mass.value),
"gas_momentum": list(momentum),
"gas_density_range": list(density_range),
"gas_dt_limits": list(dt_limits),
}
def gas_source_summary(self) -> dict[str, float | list[float]]:
mass_source = ctypes.c_double(0.0)
energy_source = ctypes.c_double(0.0)
momentum_type = ctypes.c_double * 3
momentum_source = momentum_type()
self._check(self.lib.sphlite_get_gas_source_summary(
ctypes.byref(mass_source),
momentum_source,
ctypes.byref(energy_source),
))
return {
"gas_source_mass": float(mass_source.value),
"gas_source_momentum": list(momentum_source),
"gas_source_energy": float(energy_source.value),
}
def inspect(self, filename: str | Path) -> dict[str, int | float | list[float]]:
self.read_inp(filename)
self.build_model()
@@ -344,6 +396,8 @@ class SPHLite:
summary.update(self.gas_summary())
summary.update(self.gas_bubble_metrics())
summary.update(self.gas_dt_limits())
summary.update(self.gas_extended_summary())
summary.update(self.gas_source_summary())
return summary
def run(self, filename: str | Path) -> dict[str, int | float | list[float]]:
@@ -355,4 +409,6 @@ class SPHLite:
summary.update(self.gas_summary())
summary.update(self.gas_bubble_metrics())
summary.update(self.gas_dt_limits())
summary.update(self.gas_extended_summary())
summary.update(self.gas_source_summary())
return summary