|
10 | 10 | import numpy as np |
11 | 11 | import scipy |
12 | 12 | from matplotlib import pyplot as plt |
| 13 | +import magnethub as mh |
| 14 | +import pandas as pd |
13 | 15 |
|
14 | 16 | logger = logging.getLogger(__name__) |
15 | 17 |
|
@@ -1272,3 +1274,80 @@ def calc_proximity_factor_air_gap(litz_wire_name: str, number_turns: int, r_1: f |
1272 | 1274 |
|
1273 | 1275 | proximity_factor = 1 + nominator / denominator |
1274 | 1276 | 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 |
0 commit comments