Running Parameter Surveys#
pyemsol can update analysis conditions when calculating multiple cases.
The following analysis conditions can be changed:
Update material properties:
16_1_3D_Element_Properties(16.1)Update time functions:
18_Time_Function(18)
Note
For pyemsol installation and basic information, see Running from Python.
pyemsol execution procedure (briefly)#
To run pyemsol in a Python script, call the following functions in order.
import pyemsol
# 初期化
pyemsol.initialize(json_data, current_directory)
# 計算条件の更新
for i in range(num_case):
# 計算条件の更新
# update Time_Function
# json_data["18_Time_Function"] = new_time_function
pyemsol.update_Time_Function(json_data)
# 計算実行, 計算結果の取得
output = pyemsol.solve()
# 計算終了
pyemsol.finalize()
Initialize with pyemsol.initialize, then run pyemsol.solve multiple times. Finish with pyemsol.finalize.
Because pyemsol.solve can run multiple times, analysis conditions can be changed between calculations.
Updating material properties#
To update material properties, specify is_DESIGN_DOMAIN(16.1) for the properties to designate as a design domain, as shown below.
Material properties for a property specified as "is_DESIGN_DOMAIN" : 1 can be changed in the iterative procedure shown below.
"16_Material_Properties" :
{
"EXTEND_TOTAL_for_COIL" : I,
"16_1_3D_Element_Properties" :
[
{
"MAT_ID" : I,
"POTENTIAL" : I,
"ElectricProperty" :
{
"conductivity" :
{
"comment" : "SIGMA_XYZ for anisotropic, or isotropic SIGMA if not defined.",
"SIGMA" : E
}
},
"MagneticProperty" :
{
"comment" : "MU_XYZ for anisotropic, or isotropic MU if not defined.",
"MU" : E,
"BH_CURVE_ID" : I
},
"is_DESIGN_DOMAIN" : 1
}
]
}
Use pyemsol.update_properties_in_design_domain to update material properties for a property designated as a design domain. This section describes that method.
Update material properties for a property designated as a design domain with pyemsol.update_properties_in_design_domain as follows.
import pyemsol
# 計算条件の初期化
# json_data は input.json のデータ
# current_directory は input.json のあるディレクトリ
pyemsol.initialize(json_data, current_directory)
# 材料特性の更新
# default permeability = 1.0, update to 5.0
permeability = 5.0
matData = json_data["16_Material_Properties"]
data3D = matData["16_1_3D_Element_Properties"]
for element in data3D:
if element["MAT_ID"] == 1:
element["MagneticProperty"]["MU"] = permeability
break
# 計算条件の更新
pyemsol.update_properties_in_design_domain(new_material_properties)
# 計算実行, 計算結果の取得
output = pyemsol.solve()
# 計算終了
pyemsol.finalize()
Material properties can be updated for properties with is_DESIGN_DOMAIN set to 1 in 16_1_3D_Element_Properties under 16_Material_Properties in input.json.
The example updates relative permeability MU, but other material properties can be updated in the same way. MagneticProperty itself can also be updated.
import pyemsol
# 計算条件の初期化
# json_data は input.json のデータ
# current_directory は input.json のあるディレクトリ
pyemsol.initialize(json_data, current_directory)
# Initialize variables to hold MagneticProperty values
magnetic_property_mat_id_10 = None
data3D = matData["16_1_3D_Element_Properties"]
for element in data3D:
if element["MAT_ID"] == 10:
magnetic_property_mat_id_10 = element["MagneticProperty"]
break
# 材料特性の更新
matData = json_data["16_Material_Properties"]
data3D = matData["16_1_3D_Element_Properties"]
for element in data3D:
if element["MAT_ID"] == 1:
element["MagneticProperty"] = magnetic_property_mat_id_10
break
# 計算条件の更新
pyemsol.update_properties_in_design_domain(new_material_properties)
# 計算実行, 計算結果の取得
output = pyemsol.solve()
# 計算終了
pyemsol.finalize()
This can be used for sensitivity analysis that changes materials assigned to a property, such as air or iron.
For sample code, see Sample Code for Updating Material-Property Data in the Design Domain with update_properties_in_design_domain.
Updating time functions#
Updating time functions can be used, for example, to calculate current-torque characteristics in motor analysis. Time functions are specified in 18_Time_Function(18).
This section shows an example using 交流表示(18.3).
Assume that the time function 18_Time_Function(18) shown below is connected to the electrical circuit NETWORK(17.9).
"18_Time_Function":
[
{
"TIME_ID": I,
"OPTION": 2,
"AMPLITUDE": 1.0,
"TCYCLE": 0.02,
"PHASE": 0.0
}
]
With current phase fixed at 0.0 deg, change current amplitude by updating the time-function amplitude with pyemsol.update_Time_Function as follows.
import pyemsol
# 計算条件の初期化
# json_data は input.json のデータ
# current_directory は input.json のあるディレクトリ
pyemsol.initialize(json_data, current_directory)
# 時間関数の更新
# 三相交流は,TIME_ID=1,2,3として定義されているとする。
for current in current_rms:
# 交流表示の時間関数の振幅を変更
time_function = json_data["18_Time_Function"]
for function in time_function:
if function["TIME_ID"] == 1 or function["TIME_ID"] == 2 or function["TIME_ID"] == 3:
function["AMPLITUDE"] = current
# 計算条件の更新
pyemsol.update_Time_Function(json_data)
# 計算実行, 計算結果の取得
output = pyemsol.solve()
# 計算結果の処理
# 計算終了
pyemsol.finalize()
Pass data from input.json to pyemsol.update_Time_Function because the JSON data must include the 18_Time_Function key.
To update the current phase, change PHASE.
For sample code, see Sample Code for Updating a Time Function with update_Time_Function.