.. 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 31-32 Perform required imports .. GENERATED FROM PYTHON SOURCE LINES 32-34 .. code-block:: Python import ansys.motorcad.core as pymotorcad .. GENERATED FROM PYTHON SOURCE LINES 35-36 Launch Motor-CAD .. GENERATED FROM PYTHON SOURCE LINES 36-39 .. code-block:: Python mc = pymotorcad.MotorCAD() .. GENERATED FROM PYTHON SOURCE LINES 40-43 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 43-77 .. 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 78-81 PyMotorCAD Documentation Example -------------------------------------- (Used for the PyMotorCAD Documentation Examples only) .. GENERATED FROM PYTHON SOURCE LINES 81-87 .. 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 2:56:41 PM : Python script output: 1.4 2:56:41 PM : Steady State calculation completed after 7 iterations 2:56:42 PM : Python script output: Housing Temperature: 111.8 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 49.157 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 ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: thermal_steady_state.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_