Skip to content

Commit 48c8a56

Browse files
committed
Merge branch 'main' into Add_DC_Offset_handling
2 parents d8fcc45 + 6e652ab commit 48c8a56

3 files changed

Lines changed: 103 additions & 3 deletions

File tree

docs/wordlist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ bOPET
537537
xlsxwriter
538538
Thermoset
539539
Polyphenylene
540+
LossModel
541+
mh
540542

541543
# Time domain Visualization
542544
VisualizationMode

femmt/functions_reluctance.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import numpy as np
1111
import scipy
1212
from matplotlib import pyplot as plt
13+
import magnethub as mh
14+
import pandas as pd
1315

1416
logger = logging.getLogger(__name__)
1517

@@ -1272,3 +1274,80 @@ def calc_proximity_factor_air_gap(litz_wire_name: str, number_turns: int, r_1: f
12721274

12731275
proximity_factor = 1 + nominator / denominator
12741276
return proximity_factor
1277+
1278+
def magent_loss_model_on_cylinder_radiant(magnet_material_model: mh.loss.LossModel, r_cyl_inner: np.float64, r_cyl_outer: np.float64,
1279+
time_vec: np.ndarray, flux_vec: np.ndarray, h_cyl: np.ndarray, temperature: np.float64,
1280+
total_opening_angle_rad: float = 210 / 360 * 2 * np.pi):
1281+
"""
1282+
Get the core hysteresis losses for the radiant flux parts in a tablet. Uses the MagNet model.
1283+
1284+
:param magnet_material_model: MagNet material model
1285+
:type magnet_material_model: mh.loss.LossModel
1286+
:param r_cyl_inner: inner cylinder radius of the tablet
1287+
:type r_cyl_inner: np.float64
1288+
:param r_cyl_outer: outer cylinder radius of the tablet
1289+
:type r_cyl_outer: np.float64
1290+
:param time_vec: time vector
1291+
:type time_vec: np.ndarray
1292+
:param flux_vec: flux vector
1293+
:type flux_vec: np.ndarray
1294+
:param h_cyl: height of the tablet / cylinder
1295+
:type h_cyl: np.ndarray
1296+
:param temperature: temperature in °C
1297+
:type temperature: np.float64
1298+
:param total_opening_angle_rad: cylinder/tablet total opening angle
1299+
:type total_opening_angle_rad: float
1300+
"""
1301+
1302+
def flux_density_cylinder_envelope(cylinder_radius: float | np.ndarray, flux_in_cylinder: float | np.ndarray,
1303+
height_of_cylinder: float | np.ndarray, magnet_material_model: mh.loss.LossModel,
1304+
time_vec: np.ndarray, temperature: np.float64, total_opening_angle_rad: float) -> float | np.ndarray:
1305+
"""
1306+
Helper-function, what is used as a function to integrate by scipy.integrate.quad.
1307+
1308+
It calculates the flux density in a cylinder envelope. By using the integration function, the flux density
1309+
in a volume can be calculated, as done in the superordinate function.
1310+
1311+
:param cylinder_radius: cylinder radius in m
1312+
:type cylinder_radius: float | np.ndarray
1313+
:param flux_in_cylinder: flux in Wb trough cylinder envelope depending on its radius
1314+
:type flux_in_cylinder: float | np.ndarray
1315+
:param height_of_cylinder: cylinder height in m
1316+
:type height_of_cylinder: float | np.ndarray
1317+
:param magnet_material_model: Magnet material model
1318+
:type magnet_material_model: mh.loss.LossModel
1319+
:param time_vec: time vector
1320+
:type time_vec: np.ndarray
1321+
:param temperature: temperature in degree
1322+
:type temperature: np.float64
1323+
:param total_opening_angle_rad: total opening angle in radiant
1324+
:type total_opening_angle_rad: float
1325+
:return: Flux density in T
1326+
:rtype: float | np.ndarray
1327+
"""
1328+
# calculate flux density in dependence of the radius
1329+
flux_density_middle = flux_in_cylinder / (total_opening_angle_rad * cylinder_radius * height_of_cylinder)
1330+
1331+
# prepare magnet model loss calculation
1332+
interp_points = np.arange(0, 1024) * time_vec[-1] / 1024
1333+
flux_density_middle_interp = np.interp(interp_points, time_vec, flux_density_middle)
1334+
1335+
# magnet model loss calculation
1336+
fundamental_frequency = 1 / time_vec[-1]
1337+
p_density_middle, _ = magnet_material_model(flux_density_middle_interp, fundamental_frequency, temperature)
1338+
1339+
return p_density_middle
1340+
1341+
# generate flux and loss distribution along the radius
1342+
radius_list = np.linspace(r_cyl_inner, r_cyl_outer, 10)
1343+
radius_list_df = pd.DataFrame({"radius": radius_list})
1344+
1345+
radius_list_df["p_density"] = radius_list_df.apply(
1346+
lambda x: flux_density_cylinder_envelope(
1347+
cylinder_radius=x["radius"], flux_in_cylinder=flux_vec, height_of_cylinder=h_cyl, magnet_material_model=magnet_material_model,
1348+
time_vec=time_vec, temperature=temperature, total_opening_angle_rad=total_opening_angle_rad), axis=1)
1349+
1350+
# integrate along the axis
1351+
power = total_opening_angle_rad * h_cyl * np.trapezoid(radius_list_df["p_density"] * radius_list, x=radius_list)
1352+
1353+
return power

femmt/optimization/sto.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,28 @@ def single_reluctance_model_simulation(reluctance_input: StoReluctanceModelInput
387387
ff.calculate_cylinder_volume(2 * r_outer, reluctance_input.core_inner_diameter / 4))
388388
volume_core_middle = ff.calculate_cylinder_volume(2 * r_outer, reluctance_input.core_inner_diameter / 4)
389389

390-
p_top = p_density_top * volume_core_top
391-
p_bot = p_density_bot * volume_core_bot
392-
p_middle = p_density_middle * volume_core_middle
390+
p_top_tablet = fr.magent_loss_model_on_cylinder_radiant(
391+
magnet_material_model=reluctance_input.magnet_material_model, r_cyl_inner=reluctance_input.core_inner_diameter,
392+
r_cyl_outer=r_outer, time_vec=reluctance_input.time_extracted_vec, flux_vec=flux_top,
393+
h_cyl=reluctance_input.core_inner_diameter / 4, temperature=reluctance_input.temperature)
394+
volume_core_top_cylinder = 2 * ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, reluctance_input.window_h_top) - \
395+
ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, l_top_air_gap)
396+
p_top_cylinder = p_density_top * volume_core_top_cylinder
397+
p_top = p_top_tablet + p_top_cylinder
398+
399+
p_bot_tablet = fr.magent_loss_model_on_cylinder_radiant(
400+
magnet_material_model=reluctance_input.magnet_material_model, r_cyl_inner=reluctance_input.core_inner_diameter,
401+
r_cyl_outer=r_outer, time_vec=reluctance_input.time_extracted_vec, flux_vec=flux_bot,
402+
h_cyl=reluctance_input.core_inner_diameter / 4, temperature=reluctance_input.temperature)
403+
volume_core_bot_cylinder = 2 * ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, reluctance_input.window_h_bot) - \
404+
ff.calculate_cylinder_volume(reluctance_input.core_inner_diameter, l_bot_air_gap)
405+
p_bot_cylinder = p_density_bot * volume_core_bot_cylinder
406+
p_bot = p_bot_tablet + p_bot_cylinder
407+
408+
p_middle = fr.magent_loss_model_on_cylinder_radiant(
409+
magnet_material_model=reluctance_input.magnet_material_model, r_cyl_inner=reluctance_input.core_inner_diameter,
410+
r_cyl_outer=r_outer, time_vec=reluctance_input.time_extracted_vec, flux_vec=flux_middle,
411+
h_cyl=reluctance_input.core_inner_diameter / 4, temperature=reluctance_input.temperature)
393412

394413
p_hyst = p_top + p_bot + p_middle
395414

0 commit comments

Comments
 (0)