Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions femmt/functions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Contains different functions, used by the whole FEMMT functions."""
# Python standard libraries
import json
import pkg_resources
import subprocess
import sys
import os
import warnings
from scipy.integrate import quad
import logging
import importlib.metadata

# Third parry libraries
import gmsh
from matplotlib import pyplot as plt
Expand All @@ -18,7 +19,6 @@
import schemdraw
import schemdraw.elements as elm


# Local libraries
from femmt.constants import *
from femmt.enumerations import ConductorType
Expand Down Expand Up @@ -845,11 +845,20 @@ def pm_core_inner_diameter_calculator(inner_core_diameter: float, hole_diameter:

return np.around(2 * np.sqrt(area_total / np.pi), decimals=4)

def list_installed_packages() -> set:
""""List installed python packages."""
distributions = importlib.metadata.distributions()
installed_packages = []
for dist in distributions:
args = dist.metadata['Name']
installed_packages.append(args)
set_installed_packages = set(installed_packages)
return set_installed_packages

def install_pyfemm_if_missing() -> None:
"""Installs femm-software pip package in case of running on Windows machine. Windows users only."""
required = {'pyfemm'}
installed = {pkg.key for pkg in pkg_resources.working_set}
installed = list_installed_packages()
missing = required - installed

if missing:
Expand Down
104 changes: 52 additions & 52 deletions tests/integration/fixtures/log_inductor_core_material_database.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,87 +4,87 @@
"f": 100000,
"winding1": {
"turn_losses": [
0.08186750219758603,
0.07855828152724643,
0.05047467240452998,
0.02103762007713824,
0.009397893298164508,
0.02103111578873332,
0.05067410450942035,
0.07945969275407563,
0.08423323302123231
0.0818675022071684,
0.07855828153616791,
0.05047467240932421,
0.02103762007805146,
0.009397893297526803,
0.02103111578955079,
0.05067410451406756,
0.0794596927629429,
0.08423323303106273
],
"flux": [
9.432469475968289e-05,
-4.564864467214203e-07
9.432469476716475e-05,
-4.564865668072955e-07
],
"flux_over_current": [
2.0961010508070005e-05,
-1.0490246158232937e-07
2.0961010509732907e-05,
-1.0490248826801675e-07
],
"V": [
0.2966047223854783,
59.26586096157406
0.2966047978374818,
59.26586096627581
],
"number_turns": 9,
"I": [
4.5,
0.0
],
"winding_losses": 0.4767341155781262,
"P": 0.6673606253673262,
"Q": 133.34818716354164,
"S": 133.34985710531237
"winding_losses": 0.4767341156258626,
"P": 0.667360795134334,
"Q": 133.34818717412057,
"S": 133.34985711674076
},
"core_eddy_losses": 0.005277688833746474,
"core_hyst_losses": 0.186036315606035,
"core_eddy_losses": 0.005277688833992931,
"core_hyst_losses": 0.1860364851277851,
"core_parts": {
"core_part_1": {
"eddy_losses": 0.002182820518385057,
"hyst_losses": 0.1295468431448242,
"total_core_part_1": 0.13172966366320926
"eddy_losses": 0.002182820518597349,
"hyst_losses": 0.1295469635607354,
"total_core_part_1": 0.13172978407933275
},
"core_part_2": {
"eddy_losses": 0.003094868315361419,
"hyst_losses": 0.05648947246121275,
"total_core_part_2": 0.059584340776574166
"eddy_losses": 0.003094868315395592,
"hyst_losses": 0.05648952156704907,
"total_core_part_2": 0.05958438988244466
}
},
"all_winding_losses": 0.4767341155781262
"all_winding_losses": 0.4767341156258626
}
],
"total_losses": {
"winding1": {
"total": 0.47673411557812684,
"total": 0.47673411562586276,
"turns": [
0.08186750219758603,
0.07855828152724643,
0.05047467240452998,
0.02103762007713824,
0.009397893298164508,
0.02103111578873332,
0.05067410450942035,
0.07945969275407563,
0.08423323302123231
0.0818675022071684,
0.07855828153616791,
0.05047467240932421,
0.02103762007805146,
0.009397893297526803,
0.02103111578955079,
0.05067410451406756,
0.0794596927629429,
0.08423323303106273
]
},
"all_windings": 0.4767341155781262,
"eddy_core": 0.005277688833746474,
"hyst_core_fundamental_freq": 0.186036315606035,
"total_core_part_1": 0.13172966366320926,
"total_eddy_core_part_1": 0.002182820518385057,
"total_hyst_core_part_1": 0.1295468431448242,
"total_core_part_2": 0.059584340776574166,
"total_eddy_core_part_2": 0.003094868315361419,
"total_hyst_core_part_2": 0.05648947246121275,
"core": 0.19131400443978147,
"total_losses": 0.6680481200179077
"all_windings": 0.4767341156258626,
"eddy_core": 0.005277688833992931,
"hyst_core_fundamental_freq": 0.1860364851277851,
"total_core_part_1": 0.13172978407933275,
"total_eddy_core_part_1": 0.002182820518597349,
"total_hyst_core_part_1": 0.1295469635607354,
"total_core_part_2": 0.05958438988244466,
"total_eddy_core_part_2": 0.003094868315395592,
"total_hyst_core_part_2": 0.05648952156704907,
"core": 0.19131417396177802,
"total_losses": 0.6680482895876406
},
"simulation_settings": {
"simulation_name": null,
"date": "2025-08-20 10:20:18",
"date": "2026-03-05 12:59:55",
"component_type": "Inductor",
"working_directory": "C:\\Users\\tpiepe\\Repositories\\FEM_Magnetics_Toolbox\\tests\\integration\\temp",
"working_directory": "/home/nikolasf/Dokumente/01_git/30_Python/FEMMT/tests/integration/temp",
"core": {
"core_type": 1,
"core_inner_diameter": 0.0149,
Expand Down Expand Up @@ -193,4 +193,4 @@
],
"total_cost_incl_margin": 5.471883844584376
}
}
}
Loading