.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\internal_scripting\thermal_steady_state.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_internal_scripting_thermal_steady_state.py: .. _ref_internal_scripting_thermal_steady_state: Thermal steady-state ==================== This example demonstrates internal scripting thermal steady-state functionality .. GENERATED FROM PYTHON SOURCE LINES 9-10 Perform required imports .. GENERATED FROM PYTHON SOURCE LINES 10-12 .. code-block:: Python import ansys.motorcad.core as pymotorcad .. GENERATED FROM PYTHON SOURCE LINES 13-14 Launch Motor-CAD .. GENERATED FROM PYTHON SOURCE LINES 14-17 .. code-block:: Python mc = pymotorcad.MotorCAD() .. GENERATED FROM PYTHON SOURCE LINES 18-21 We will update the resistance between nodes with the following equation: resistance = (0.01 × ambient_temp) + 1 This function is called when "Run" is pressed .. GENERATED FROM PYTHON SOURCE LINES 21-55 .. code-block:: Python def main(): pass class thermal_steady: # Select nodes to update housing_node = 1 ambient_node = 0 def initial(self): # %% # Disable pop-up messages mc.set_variable("MessageDisplayState", 2) # Adjust Losses mc.display_screen("Scripting") mc.set_variable("Armature_Copper_Loss_@Ref_Speed", 200) def main(self): ambient_temp = mc.get_variable("T_Ambient") resistance = (ambient_temp * 0.01) + 1 mc.set_resistance_value( "Custom Resistance", self.ambient_node, self.housing_node, resistance, "" ) print(str(resistance)) def final(self): # Get temperature from node housing_temp = mc.get_node_temperature(self.housing_node) print("Housing Temperature: " + str(round(housing_temp, 1))) mc.set_variable("MessageDisplayState", 0) .. GENERATED FROM PYTHON SOURCE LINES 56-59 PyMotorCAD Documentation Example -------------------------------------- (Used for the PyMotorCAD Documentation Examples only) .. GENERATED FROM PYTHON SOURCE LINES 59-65 .. code-block:: Python try: from setup_scripts.setup_script import run_thermal_steady_demo except ImportError: pass else: run_thermal_steady_demo(mc) .. rst-class:: sphx-glr-script-out .. code-block:: none Armature copper loss = 200 11:34:37 AM : Python script output: 1.4 11:34:37 AM : Steady State calculation completed after 7 iterations 11:34:38 AM : Python script output: Housing Temperature: 105.3 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 21.860 seconds) .. _sphx_glr_download_examples_internal_scripting_thermal_steady_state.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: thermal_steady_state.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: thermal_steady_state.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_