|
@@ -88,7 +88,7 @@ def write_and_verify(mc, variable: str, value: float) -> None:
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
-def main(mode: str = "steady") -> int:
|
|
|
|
|
|
|
+def main(mode: str = "steady", ambient: float = None) -> int:
|
|
|
ensure_environment()
|
|
ensure_environment()
|
|
|
|
|
|
|
|
import ansys.motorcad.core as pymotorcad
|
|
import ansys.motorcad.core as pymotorcad
|
|
@@ -120,6 +120,13 @@ def main(mode: str = "steady") -> int:
|
|
|
except Exception as exc: # noqa: BLE001
|
|
except Exception as exc: # noqa: BLE001
|
|
|
log(" WARNING: %s write failed: %s" % (var, exc))
|
|
log(" WARNING: %s write failed: %s" % (var, exc))
|
|
|
|
|
|
|
|
|
|
+ if ambient is not None:
|
|
|
|
|
+ try:
|
|
|
|
|
+ write_and_verify(mc, "Ambient_Temperature", ambient)
|
|
|
|
|
+ log(" Ambient_Temperature = %s (override, verified)" % ambient)
|
|
|
|
|
+ except Exception as exc: # noqa: BLE001
|
|
|
|
|
+ log(" WARNING: Ambient_Temperature write failed: %s" % exc)
|
|
|
|
|
+
|
|
|
if mode == "coupled":
|
|
if mode == "coupled":
|
|
|
# Magnetic-thermal coupled solve: EM + thermal in one call.
|
|
# Magnetic-thermal coupled solve: EM + thermal in one call.
|
|
|
log("Running magnetic-thermal coupled calculation ...")
|
|
log("Running magnetic-thermal coupled calculation ...")
|
|
@@ -196,9 +203,16 @@ if __name__ == "__main__":
|
|
|
help="steady = EM then steady-state thermal (default); "
|
|
help="steady = EM then steady-state thermal (default); "
|
|
|
"coupled = do_magnetic_thermal_calculation (EM+thermal in one).",
|
|
"coupled = do_magnetic_thermal_calculation (EM+thermal in one).",
|
|
|
)
|
|
)
|
|
|
|
|
+ parser.add_argument(
|
|
|
|
|
+ "--ambient",
|
|
|
|
|
+ type=float,
|
|
|
|
|
+ default=None,
|
|
|
|
|
+ help="override Ambient_Temperature (degC). Default uses the model "
|
|
|
|
|
+ "value (MARS model ships 125, which is abnormal; try 25 or 40).",
|
|
|
|
|
+ )
|
|
|
args = parser.parse_args()
|
|
args = parser.parse_args()
|
|
|
try:
|
|
try:
|
|
|
- sys.exit(main(mode=args.mode))
|
|
|
|
|
|
|
+ sys.exit(main(mode=args.mode, ambient=args.ambient))
|
|
|
except Exception:
|
|
except Exception:
|
|
|
traceback.print_exc()
|
|
traceback.print_exc()
|
|
|
sys.exit(1)
|
|
sys.exit(1)
|