Skip to content

Commit 1c21b37

Browse files
committed
speed up hysteresis losses by magnet model in radiant-flux-cylinders
1 parent 28d95b0 commit 1c21b37

2 files changed

Lines changed: 42 additions & 14 deletions

File tree

femmt/functions_reluctance.py

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import scipy
1212
from matplotlib import pyplot as plt
1313
import magnethub as mh
14+
import pandas as pd
1415

1516
logger = logging.getLogger(__name__)
1617

@@ -1271,7 +1272,28 @@ def calc_proximity_factor_air_gap(litz_wire_name: str, number_turns: int, r_1: f
12711272
return proximity_factor
12721273

12731274
def magent_loss_model_on_cylinder_radiant(magnet_material_model: mh.loss.LossModel, r_cyl_inner: np.float64, r_cyl_outer: np.float64,
1274-
time_vec: np.ndarray, flux_vec: np.ndarray, h_cyl: np.ndarray, temperature: np.float64, total_opening_angle_rad: float = 210 / 360 * 2 * np.pi):
1275+
time_vec: np.ndarray, flux_vec: np.ndarray, h_cyl: np.ndarray, temperature: np.float64,
1276+
total_opening_angle_rad: float = 210 / 360 * 2 * np.pi):
1277+
"""
1278+
Get the core hysteresis losses for the radiant flux parts in a tablet. Uses the MagNet model.
1279+
1280+
:param magnet_material_model: MagNet material model
1281+
:type magnet_material_model: mh.loss.LossModel
1282+
:param r_cyl_inner: inner cylinder radius of the tablet
1283+
:type r_cyl_inner: np.float64
1284+
:param r_cyl_outer: outer cylinder radius of the tablet
1285+
:type r_cyl_outer: np.float64
1286+
:param time_vec: time vector
1287+
:type time_vec: np.ndarray
1288+
:param flux_vec: flux vector
1289+
:type flux_vec: np.ndarray
1290+
:param h_cyl: height of the tablet / cylinder
1291+
:type h_cyl: np.ndarray
1292+
:param temperature: temperature in °C
1293+
:type temperature: np.float64
1294+
:param total_opening_angle_rad: cylinder/tablet total opening angle
1295+
:type total_opening_angle_rad: float
1296+
"""
12751297

12761298
def flux_density_cylinder_envelope(cylinder_radius: float | np.ndarray, flux_in_cylinder: float | np.ndarray,
12771299
height_of_cylinder: float | np.ndarray, magnet_material_model: mh.loss.LossModel,
@@ -1288,6 +1310,14 @@ def flux_density_cylinder_envelope(cylinder_radius: float | np.ndarray, flux_in_
12881310
:type flux_in_cylinder: float | np.ndarray
12891311
:param height_of_cylinder: cylinder height in m
12901312
:type height_of_cylinder: float | np.ndarray
1313+
:param magnet_material_model: Magnet material model
1314+
:type magnet_material_model: mh.loss.LossModel
1315+
:param time_vec: time vector
1316+
:type time_vec: np.ndarray
1317+
:param temperature: temperature in degree
1318+
:type temperature: np.float64
1319+
:param total_opening_angle_rad: total opening angle in radiant
1320+
:type total_opening_angle_rad: float
12911321
:return: Flux density in T
12921322
:rtype: float | np.ndarray
12931323
"""
@@ -1302,20 +1332,18 @@ def flux_density_cylinder_envelope(cylinder_radius: float | np.ndarray, flux_in_
13021332
fundamental_frequency = 1 / time_vec[-1]
13031333
p_density_middle, _ = magnet_material_model(flux_density_middle_interp, fundamental_frequency, temperature)
13041334

1305-
return flux_density_middle, p_density_middle
1335+
return p_density_middle
13061336

13071337
# generate flux and loss distribution along the radius
1308-
radius_list = np.linspace(r_cyl_inner, r_cyl_outer)
1309-
flux_density_list = []
1310-
p_density_list = []
1311-
for radius in radius_list:
1312-
flux_density_middle, p_density_middle = flux_density_cylinder_envelope(
1313-
cylinder_radius=radius, flux_in_cylinder=flux_vec, height_of_cylinder=h_cyl, magnet_material_model=magnet_material_model,
1314-
time_vec=time_vec, temperature=temperature, total_opening_angle_rad=total_opening_angle_rad)
1315-
flux_density_list.append(flux_density_middle)
1316-
p_density_list.append(p_density_middle)
1338+
radius_list = np.linspace(r_cyl_inner, r_cyl_outer, 10)
1339+
radius_list_df = pd.DataFrame({"radius": radius_list})
1340+
1341+
radius_list_df["p_density"] = radius_list_df.apply(
1342+
lambda x: flux_density_cylinder_envelope(
1343+
cylinder_radius=x["radius"], flux_in_cylinder=flux_vec, height_of_cylinder=h_cyl, magnet_material_model=magnet_material_model,
1344+
time_vec=time_vec, temperature=temperature, total_opening_angle_rad=total_opening_angle_rad), axis=1)
13171345

13181346
# integrate along the axis
1319-
power = total_opening_angle_rad * h_cyl * np.trapezoid(p_density_list * radius_list, x=radius_list)
1347+
power = total_opening_angle_rad * h_cyl * np.trapezoid(radius_list_df["p_density"] * radius_list, x=radius_list)
13201348

13211349
return power

femmt/optimization/sto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def single_reluctance_model_simulation(reluctance_input: StoReluctanceModelInput
396396
r_cyl_outer=r_outer, time_vec=reluctance_input.time_extracted_vec, flux_vec=flux_top,
397397
h_cyl=reluctance_input.core_inner_diameter / 4, temperature=reluctance_input.temperature)
398398
volume_core_top_cylinder = 2 * ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, reluctance_input.window_h_top) - \
399-
ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, l_top_air_gap)
399+
ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, l_top_air_gap)
400400
p_top_cylinder = p_density_top * volume_core_top_cylinder
401401
p_top = p_top_tablet + p_top_cylinder
402402

@@ -405,7 +405,7 @@ def single_reluctance_model_simulation(reluctance_input: StoReluctanceModelInput
405405
r_cyl_outer=r_outer, time_vec=reluctance_input.time_extracted_vec, flux_vec=flux_bot,
406406
h_cyl=reluctance_input.core_inner_diameter / 4, temperature=reluctance_input.temperature)
407407
volume_core_bot_cylinder = 2 * ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, reluctance_input.window_h_bot) - \
408-
ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, l_bot_air_gap)
408+
ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, l_bot_air_gap)
409409
p_bot_cylinder = p_density_bot * volume_core_bot_cylinder
410410
p_bot = p_bot_tablet + p_bot_cylinder
411411

0 commit comments

Comments
 (0)