Current, electric potential and other parameters that change depending on time, angle, etc., can be defined using point sequences or functions.
JMAG-Designer provides functions such as harmonics, pulse, sine wave, constant, step and exponential.
This script defines changes in current, electric potential and current density using these functions.
Preconditions
- One or more magnetic field transient analysis studies have been created.
This script runs on the active magnetic field transient analysis study in the project tree.
Script Function
- Define the change in condition: current as a sine wave function.
A sine wave is defined by amplitude, frequency and phase. - Define the change in condition: current density as a harmonic function.
Harmonics are defined by the fundamental wave and the amplitude and relative phase of each order. - Define the change in potential of the circuit component: electric potential source (1 terminal) as a constant value.
- Define the change in potential of the circuit component: electric potential source (2 terminals) as an exponential function.
An exponential function is defined by amplitude, asymptotic value, and time constant.
# 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/
app = designer.GetApplication()
def createFunctionObjSin(amp, freq, phase):
"""Generate function (sine wave)"""
funcObjFac = app.FunctionFactory()
funcObj = funcObjFac.Sin(amp, freq, phase, False)
return funcObj
def createDataSetHarmonic():
"""Create a dataset to set to harmonics."""
dataMng = app.GetDataManager()
dataSet = dataMng.CreatePointArray(u"harmonic_amplitudes", u"val")
refarray = [[0 for i in range(2)] for j in range(4)]
refarray[0][0] = 2 # Amplitude of 2nd order
refarray[0][1] = 0 # Relative phase of 2nd order
refarray[1][0] = 1 # 3rd
refarray[1][1] = 60
refarray[2][0] = 0 # 4th
refarray[2][1] = 0
refarray[3][0] = 1 # 5th
refarray[3][1] = 120
dataSet.SetTable(refarray)
return dataSet
def createFunctionObjHarmonic(amp, freq, phase):
"""Generate function (harmonic)"""
funcObjFac = app.FunctionFactory()
funcObj = funcObjFac.Harmonic(amp, freq, phase)
return funcObj
def createFunctionObjConstant(amp):
"""Generate function (a constant value)"""
funcObjFac = app.FunctionFactory()
funcObj = funcObjFac.Constant(20)
return funcObj
def createFunctionObjExp(amp, initial, time):
"""Generate function (exponential function)"""
funcObjFac = app.FunctionFactory()
funcObj = funcObjFac.Exp(amp, initial, time)
return funcObj
study = app.GetCurrentStudy()
amp = 3.46
freq = 315
phase = 0
isRMS = True
functionObj = createFunctionObjSin(amp, freq, phase)
cond = study.GetCondition(u"current_1")
cond.SetFunction(functionObj)
amp = 20
freq = 60
dataSet = createDataSetHarmonic()
functionObj = createFunctionObjHarmonic(amp, freq, phase)
functionObj.SetTableProperty(u"Harmonics", dataSet)
cond = study.GetCondition(u"current_density_1")
cond.SetFunction(functionObj)
circuit = study.GetCircuit()
compo = circuit.GetComponent(u"V1")
functionObj = createFunctionObjConstant(amp)
compo.SetFunction(functionObj)
compo = circuit.GetComponent(u"V2")
initial = 10
time = 5
functionObj = createFunctionObjExp(amp, initial, time)
compo.SetFunction(functionObj)


