13from typing
import Dict, List, Tuple, Optional, Any
29 """Validates dimensional consistency of physical quantities"""
33 "length": [1, 0, 0, 0, 0, 0, 0],
34 "mass": [0, 1, 0, 0, 0, 0, 0],
35 "time": [0, 0, 1, 0, 0, 0, 0],
36 "temperature": [0, 0, 0, 1, 0, 0, 0],
37 "pressure": [-1, 1, -2, 0, 0, 0, 0],
38 "density": [-3, 1, 0, 0, 0, 0, 0],
39 "velocity": [1, 0, -1, 0, 0, 0, 0],
40 "force": [1, 1, -2, 0, 0, 0, 0],
41 "energy": [2, 1, -2, 0, 0, 0, 0],
42 "power": [2, 1, -3, 0, 0, 0, 0],
43 "mass_flow": [0, 1, -1, 0, 0, 0, 0],
44 "heat_flux": [0, 1, -3, 0, 0, 0, 0],
45 "viscosity": [-1, 1, -1, 0, 0, 0, 0],
46 "thermal_conductivity": [1, 1, -3, -1, 0, 0, 0],
47 "specific_heat": [2, 0, -2, -1, 0, 0, 0],
51 def validate_equation(cls, left_side: Dict[str, float], right_side: Dict[str, float]) -> bool:
53 Validate that left_side and right_side have same dimensions.
58 {quantity_name: value} where quantity_name is a key in DIMENSIONS
60 Same format as left_side
66 left_dims = np.zeros(7)
67 right_dims = np.zeros(7)
69 for name, value
in left_side.items():
71 left_dims += np.array(cls.
DIMENSIONS[name]) * value
73 for name, value
in right_side.items():
75 right_dims += np.array(cls.
DIMENSIONS[name]) * value
77 return np.allclose(left_dims, right_dims, atol=1e-10)
386) -> List[ValidationResult]:
388 Comprehensive validation of engine state.
390 Returns list of validation results (errors first, then warnings, then info).
395 results.append(PhysicalConstraints.validate_pressure(Pc,
"Pc"))
396 results.append(PhysicalConstraints.validate_temperature(Tc,
"Tc"))
397 results.append(PhysicalConstraints.validate_mass_flow(mdot_total,
"mdot_total"))
398 results.append(PhysicalConstraints.validate_mixture_ratio(MR))
399 results.append(PhysicalConstraints.validate_gamma(gamma))
400 results.append(PhysicalConstraints.validate_cstar(cstar))
401 results.append(PhysicalConstraints.validate_isp(Isp))
408 severity_order = {
"error": 0,
"warning": 1,
"info": 2}
409 results.sort(key=
lambda r: severity_order.get(r.severity, 3))