# Copyright (c) 2026 JSOL CORPORATION # # This script is released under the MIT License. # See the full license text at: # https://www.jmag-international.com/scriptlibrary/jmag_script_library_mit/ def getCircuitInStudy(study): """Retrieve the Circuit object from the study.if it does not exist, create a new circuit""" if study.HasCircuit(): circuit = study.GetCircuit() else: circuit = study.CreateCircuit() return circuit def createCoilEndCoolingWithThermalProbe(circuit, targetCompName): """Place the coil end cooling element and temperature probe element in the circuit""" CECComp = circuit.CreateComponent(u"CoilEndCooling", targetCompName) posX = -2 posY = 8 circuit.CreateComponentInstance(CECComp, posX, posY) TPComp = circuit.CreateComponent(u"ThermalProbe", u"TP") # Place the temperature probe on the terminal of the coil end cooling element circuit.CreateComponentInstance(TPComp, posX, posY + 3) CECComp.SetValue(u"ThermalResistance", 0.016) CECComp.SetValue(u"HeatCapacity", 0.012) CECComp.SetValue(u"CoolingType", u"Thermal Resistance (Constant)") CECComp.SetValue(u"ThermalResistanceCooling1", 1.2) CECComp.SetValue(u"MonitorCoilEndTemp", u"On") def createConditionOfSameTemperatureBoundaryPattern(study, targetCompName, patternOriginalFaceSet): """Create an isothermal boundary pattern (rotation) condition and associate the specified coil end cooling element""" condition = study.CreateCondition(u"SameTemperatureBoundaryPattern", targetCompName) # The title of the coil end cooling component must be unique in order to do SetLink by component name condition.SetLink(targetCompName) condition.SetValue(u"NumCopies", u"SLOTS") condition.AddSet(patternOriginalFaceSet, 0) def applyCsvResultTypeOnTerminalTemperature(study): """Enable Terminal Temperature (Thermal Circuit) in the CSV output settings for Study Properties""" study.GetStudyProperties().SetValue(u"CsvResultTypes", u"TerminalTemperature") app = designer.GetApplication() study = app.GetCurrentStudy() circuit = getCircuitInStudy(study) circuitCompName = u"up" createCoilEndCoolingWithThermalProbe(circuit, circuitCompName) set = app.GetCurrentModel().GetSetList().GetSet(u"CoilSet") createConditionOfSameTemperatureBoundaryPattern(study, circuitCompName, set) applyCsvResultTypeOnTerminalTemperature(study)