PyOpenMagnetics 1.1.0__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/PKG-INFO +1 -1
  2. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/pyproject.toml +1 -1
  3. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/advisers.cpp +89 -19
  4. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/common.h +3 -0
  5. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/simulation.cpp +216 -0
  6. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/simulation.h +12 -0
  7. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/.github/workflows/ci.yml +0 -0
  8. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/.github/workflows/publish.yml +0 -0
  9. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/.gitignore +0 -0
  10. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/CMakeLists.txt +0 -0
  11. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/LICENSE +0 -0
  12. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/PyOpenMagnetics.pyi +0 -0
  13. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/README.md +0 -0
  14. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/api/MAS.py +0 -0
  15. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/api/mas_db_reader.py +0 -0
  16. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/api/validation.py +0 -0
  17. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/docs/compatibility.md +0 -0
  18. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/docs/errors.md +0 -0
  19. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/docs/performance.md +0 -0
  20. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/examples/README.md +0 -0
  21. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/examples/buck_inductor.py +0 -0
  22. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/examples/flyback_design.py +0 -0
  23. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/llms.txt +0 -0
  24. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/notebooks/01_getting_started.ipynb +0 -0
  25. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/notebooks/02_buck_inductor.ipynb +0 -0
  26. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/notebooks/03_core_losses.ipynb +0 -0
  27. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/notebooks/README.md +0 -0
  28. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/requirements.txt +0 -0
  29. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/advisers.h +0 -0
  30. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/bobbin.cpp +0 -0
  31. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/bobbin.h +0 -0
  32. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/core.cpp +0 -0
  33. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/core.h +0 -0
  34. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/database.cpp +0 -0
  35. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/database.h +0 -0
  36. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/losses.cpp +0 -0
  37. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/losses.h +0 -0
  38. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/module.cpp +0 -0
  39. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/plotting.cpp +0 -0
  40. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/plotting.h +0 -0
  41. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/settings.cpp +0 -0
  42. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/settings.h +0 -0
  43. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/utils.cpp +0 -0
  44. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/utils.h +0 -0
  45. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/winding.cpp +0 -0
  46. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/winding.h +0 -0
  47. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/wire.cpp +0 -0
  48. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/src/wire.h +0 -0
  49. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/test.py +0 -0
  50. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/__init__.py +0 -0
  51. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/conftest.py +0 -0
  52. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/test_core.py +0 -0
  53. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/test_core_adviser.py +0 -0
  54. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/test_examples_integration.py +0 -0
  55. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/test_inputs.py +0 -0
  56. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/test_magnetic_adviser.py +0 -0
  57. {pyopenmagnetics-1.1.0 → pyopenmagnetics-1.1.2}/tests/test_winding.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyOpenMagnetics
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: Python wrapper for OpenMagnetics
5
5
  Author-Email: Alfonso Martinez <Alfonso_VII@hotmail.com>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"
4
4
 
5
5
  [project]
6
6
  name = "PyOpenMagnetics"
7
- version = "1.1.0"
7
+ version = "1.1.2"
8
8
  requires-python = ">=3.8"
9
9
  authors = [
10
10
  { name="Alfonso Martinez", email="Alfonso_VII@hotmail.com" },
@@ -24,12 +24,31 @@ json calculate_advised_cores(json inputsJson, json weightsJson, int maximumNumbe
24
24
  coreAdviser.set_mode(coreMode);
25
25
  auto masMagnetics = coreAdviser.get_advised_core(inputs, weights, maximumNumberResults);
26
26
 
27
- json results = json::array();
28
- for (auto& masMagnetic : masMagnetics) {
29
- json aux;
30
- to_json(aux, masMagnetic.first);
31
- results.push_back(aux);
27
+ auto scoringsPerFilter = coreAdviser.get_scorings();
28
+
29
+ json results = json();
30
+ results["data"] = json::array();
31
+ for (auto& [masMagnetic, scoring] : masMagnetics) {
32
+ std::string name = masMagnetic.get_magnetic().get_manufacturer_info().value().get_reference().value();
33
+ json result;
34
+ json masJson;
35
+ to_json(masJson, masMagnetic);
36
+ result["mas"] = masJson;
37
+ result["scoring"] = scoring;
38
+ if (scoringsPerFilter.count(name)) {
39
+ json filterScorings;
40
+ for (auto& [filter, filterScore] : scoringsPerFilter[name]) {
41
+ filterScorings[std::string(magic_enum::enum_name(filter))] = filterScore;
42
+ }
43
+ result["scoringPerFilter"] = filterScorings;
44
+ }
45
+ results["data"].push_back(result);
32
46
  }
47
+
48
+ sort(results["data"].begin(), results["data"].end(), [](json& b1, json& b2) {
49
+ return b1["scoring"] > b2["scoring"];
50
+ });
51
+
33
52
  OpenMagnetics::settings.reset();
34
53
 
35
54
  return results;
@@ -51,13 +70,31 @@ json calculate_advised_magnetics(json inputsJson, int maximumNumberResults, json
51
70
  magneticAdviser.set_core_mode(coreMode);
52
71
  auto masMagnetics = magneticAdviser.get_advised_magnetic(inputs, maximumNumberResults);
53
72
 
54
- json results = json::array();
73
+ auto scoringsPerFilter = magneticAdviser.get_scorings();
74
+
75
+ json results = json();
76
+ results["data"] = json::array();
55
77
  for (auto& [masMagnetic, scoring] : masMagnetics) {
56
- json aux;
57
- to_json(aux, masMagnetic);
58
- results.push_back(aux);
78
+ std::string name = masMagnetic.get_magnetic().get_manufacturer_info().value().get_reference().value();
79
+ json result;
80
+ json masJson;
81
+ to_json(masJson, masMagnetic);
82
+ result["mas"] = masJson;
83
+ result["scoring"] = scoring;
84
+ if (scoringsPerFilter.count(name)) {
85
+ json filterScorings;
86
+ for (auto& [filter, filterScore] : scoringsPerFilter[name]) {
87
+ filterScorings[std::string(magic_enum::enum_name(filter))] = filterScore;
88
+ }
89
+ result["scoringPerFilter"] = filterScorings;
90
+ }
91
+ results["data"].push_back(result);
59
92
  }
60
93
 
94
+ sort(results["data"].begin(), results["data"].end(), [](json& b1, json& b2) {
95
+ return b1["scoring"] > b2["scoring"];
96
+ });
97
+
61
98
  return results;
62
99
  }
63
100
  catch (const std::exception &exc) {
@@ -83,7 +120,7 @@ json calculate_advised_magnetics_from_catalog(json inputsJson, json catalogJson,
83
120
  OpenMagnetics::MagneticAdviser magneticAdviser;
84
121
  auto masMagnetics = magneticAdviser.get_advised_magnetic(inputs, catalog, maximumNumberResults);
85
122
 
86
- auto scorings = magneticAdviser.get_scorings();
123
+ auto scoringsPerFilter = magneticAdviser.get_scorings();
87
124
 
88
125
  json results = json();
89
126
  results["data"] = json::array();
@@ -94,6 +131,13 @@ json calculate_advised_magnetics_from_catalog(json inputsJson, json catalogJson,
94
131
  to_json(masJson, masMagnetic);
95
132
  result["mas"] = masJson;
96
133
  result["scoring"] = scoring;
134
+ if (scoringsPerFilter.count(name)) {
135
+ json filterScorings;
136
+ for (auto& [filter, filterScore] : scoringsPerFilter[name]) {
137
+ filterScorings[std::string(magic_enum::enum_name(filter))] = filterScore;
138
+ }
139
+ result["scoringPerFilter"] = filterScorings;
140
+ }
97
141
  results["data"].push_back(result);
98
142
  }
99
143
 
@@ -129,7 +173,7 @@ json calculate_advised_magnetics_from_cache(json inputsJson, json filterFlowJson
129
173
  OpenMagnetics::MagneticAdviser magneticAdviser;
130
174
  auto masMagnetics = magneticAdviser.get_advised_magnetic(inputs, OpenMagnetics::magneticsCache.get(), filterFlow, maximumNumberResults);
131
175
 
132
- auto scorings = magneticAdviser.get_scorings();
176
+ auto scoringsPerFilter = magneticAdviser.get_scorings();
133
177
 
134
178
  json results = json();
135
179
  results["data"] = json::array();
@@ -140,6 +184,13 @@ json calculate_advised_magnetics_from_cache(json inputsJson, json filterFlowJson
140
184
  to_json(masJson, masMagnetic);
141
185
  result["mas"] = masJson;
142
186
  result["scoring"] = scoring;
187
+ if (scoringsPerFilter.count(name)) {
188
+ json filterScorings;
189
+ for (auto& [filter, filterScore] : scoringsPerFilter[name]) {
190
+ filterScorings[std::string(magic_enum::enum_name(filter))] = filterScore;
191
+ }
192
+ result["scoringPerFilter"] = filterScorings;
193
+ }
143
194
  results["data"].push_back(result);
144
195
  }
145
196
 
@@ -171,13 +222,19 @@ void register_adviser_bindings(py::module& m) {
171
222
  core_mode_json: Core selection mode - "AVAILABLE_CORES" or "STANDARD_CORES".
172
223
 
173
224
  Returns:
174
- JSON array of recommended cores sorted by score (best first).
175
- Each element contains core data with functional and processed descriptions.
225
+ JSON object with "data" array containing ranked results.
226
+ Each result has:
227
+ - "mas": Mas object with magnetic data
228
+ - "scoring": Overall float score
229
+ - "scoringPerFilter": Object with individual scores per filter
230
+ (e.g., {"COST": 0.8, "EFFICIENCY": 0.9, "DIMENSIONS": 0.7})
176
231
 
177
232
  Example:
178
233
  >>> inputs = PyMKF.process_inputs(raw_inputs)
179
234
  >>> weights = {"COST": 1, "EFFICIENCY": 1, "DIMENSIONS": 0.5}
180
- >>> cores = PyMKF.calculate_advised_cores(inputs, weights, 10, "AVAILABLE_CORES")
235
+ >>> result = PyMKF.calculate_advised_cores(inputs, weights, 10, "AVAILABLE_CORES")
236
+ >>> for item in result["data"]:
237
+ ... print(f"Score: {item['scoring']}, Per filter: {item['scoringPerFilter']}")
181
238
  )pbdoc",
182
239
  py::arg("inputs_json"), py::arg("weights_json"),
183
240
  py::arg("max_results"), py::arg("core_mode_json"));
@@ -197,12 +254,18 @@ void register_adviser_bindings(py::module& m) {
197
254
  core_mode_json: Core selection mode - "AVAILABLE_CORES" or "STANDARD_CORES".
198
255
 
199
256
  Returns:
200
- JSON array of complete Mas objects sorted by score (best first).
201
- Each Mas contains: magnetic (core + coil), inputs, and optionally outputs.
257
+ JSON object with "data" array containing ranked results.
258
+ Each result has:
259
+ - "mas": Mas object with magnetic, inputs, and optionally outputs
260
+ - "scoring": Overall float score
261
+ - "scoringPerFilter": Object with individual scores per filter
262
+ (e.g., {"COST": 0.8, "LOSSES": 0.9, "DIMENSIONS": 0.7})
202
263
 
203
264
  Example:
204
265
  >>> inputs = PyMKF.process_inputs(raw_inputs)
205
- >>> magnetics = PyMKF.calculate_advised_magnetics(inputs, 5, "AVAILABLE_CORES")
266
+ >>> result = PyMKF.calculate_advised_magnetics(inputs, 5, "AVAILABLE_CORES")
267
+ >>> for item in result["data"]:
268
+ ... print(f"Score: {item['scoring']}, Per filter: {item['scoringPerFilter']}")
206
269
  )pbdoc",
207
270
  py::arg("inputs_json"), py::arg("max_results"), py::arg("core_mode_json"));
208
271
 
@@ -220,14 +283,17 @@ void register_adviser_bindings(py::module& m) {
220
283
 
221
284
  Returns:
222
285
  JSON object with "data" array containing ranked results.
223
- Each result has "mas" (Mas object) and "scoring" (float score).
286
+ Each result has:
287
+ - "mas": Mas object with magnetic data
288
+ - "scoring": Overall float score
289
+ - "scoringPerFilter": Object with individual scores per filter
224
290
 
225
291
  Example:
226
292
  >>> inputs = PyMKF.process_inputs(raw_inputs)
227
293
  >>> catalog = [magnetic1, magnetic2, magnetic3]
228
294
  >>> result = PyMKF.calculate_advised_magnetics_from_catalog(inputs, catalog, 5)
229
295
  >>> for item in result["data"]:
230
- ... print(f"Score: {item['scoring']}")
296
+ ... print(f"Score: {item['scoring']}, Per filter: {item['scoringPerFilter']}")
231
297
  )pbdoc",
232
298
  py::arg("inputs_json"), py::arg("catalog_json"), py::arg("max_results"));
233
299
 
@@ -247,6 +313,10 @@ void register_adviser_bindings(py::module& m) {
247
313
  Returns:
248
314
  JSON object with "data" array containing ranked results,
249
315
  or error string if cache is empty.
316
+ Each result has:
317
+ - "mas": Mas object with magnetic data
318
+ - "scoring": Overall float score
319
+ - "scoringPerFilter": Object with individual scores per filter
250
320
 
251
321
  Note:
252
322
  Cache must be populated before calling this function.
@@ -25,8 +25,11 @@
25
25
  #include "physical_models/Resistivity.h"
26
26
  #include "physical_models/CoreTemperature.h"
27
27
  #include "physical_models/LeakageInductance.h"
28
+ #include "physical_models/Inductance.h"
29
+ #include "physical_models/StrayCapacitance.h"
28
30
  #include "physical_models/WindingOhmicLosses.h"
29
31
  #include "physical_models/WindingSkinEffectLosses.h"
32
+ #include "physical_models/WindingLosses.h"
30
33
  #include "processors/Inputs.h"
31
34
  #include "processors/MagneticSimulator.h"
32
35
  #include "processors/CircuitSimulatorInterface.h"
@@ -190,6 +190,126 @@ json extract_column_names(json fileJson) {
190
190
  }
191
191
  }
192
192
 
193
+ json calculate_inductance_matrix(json magneticJson, double frequency, json modelsData) {
194
+ try {
195
+ OpenMagnetics::Magnetic magnetic(magneticJson);
196
+
197
+ auto reluctanceModelName = OpenMagnetics::defaults.reluctanceModelDefault;
198
+ if (!modelsData.is_null() && modelsData.find("reluctance") != modelsData.end()) {
199
+ OpenMagnetics::from_json(modelsData["reluctance"], reluctanceModelName);
200
+ }
201
+
202
+ OpenMagnetics::Inductance inductance(reluctanceModelName);
203
+ auto inductanceMatrix = inductance.calculate_inductance_matrix(magnetic, frequency);
204
+
205
+ json result;
206
+ to_json(result, inductanceMatrix);
207
+ return result;
208
+ }
209
+ catch (const std::exception &exc) {
210
+ json exception;
211
+ exception["data"] = "Exception: " + std::string{exc.what()};
212
+ return exception;
213
+ }
214
+ }
215
+
216
+ json calculate_leakage_inductance(json magneticJson, double frequency, size_t sourceIndex) {
217
+ try {
218
+ OpenMagnetics::Magnetic magnetic(magneticJson);
219
+
220
+ auto leakageInductanceOutput = OpenMagnetics::LeakageInductance().calculate_leakage_inductance_all_windings(magnetic, frequency, sourceIndex);
221
+
222
+ json result;
223
+ to_json(result, leakageInductanceOutput);
224
+ return result;
225
+ }
226
+ catch (const std::exception &exc) {
227
+ json exception;
228
+ exception["data"] = "Exception: " + std::string{exc.what()};
229
+ return exception;
230
+ }
231
+ }
232
+
233
+ json calculate_dc_resistance_per_winding(json coilJson, double temperature) {
234
+ try {
235
+ OpenMagnetics::Coil coil(coilJson, false);
236
+
237
+ auto resistances = OpenMagnetics::WindingOhmicLosses::calculate_dc_resistance_per_winding(coil, temperature);
238
+
239
+ json result = resistances;
240
+ return result;
241
+ }
242
+ catch (const std::exception &exc) {
243
+ json exception;
244
+ exception["data"] = "Exception: " + std::string{exc.what()};
245
+ return exception;
246
+ }
247
+ }
248
+
249
+ json calculate_resistance_matrix(json magneticJson, double temperature, double frequency) {
250
+ try {
251
+ OpenMagnetics::Magnetic magnetic(magneticJson);
252
+
253
+ OpenMagnetics::WindingLosses windingLosses;
254
+ auto resistanceMatrix = windingLosses.calculate_resistance_matrix(magnetic, temperature, frequency);
255
+
256
+ json result;
257
+ to_json(result, resistanceMatrix);
258
+ return result;
259
+ }
260
+ catch (const std::exception &exc) {
261
+ json exception;
262
+ exception["data"] = "Exception: " + std::string{exc.what()};
263
+ return exception;
264
+ }
265
+ }
266
+
267
+ json calculate_stray_capacitance(json coilJson, json operatingPointJson, json modelsData) {
268
+ try {
269
+ OpenMagnetics::Coil coil(coilJson, false);
270
+ OperatingPoint operatingPoint(operatingPointJson);
271
+
272
+ auto strayCapacitanceModelName = OpenMagnetics::StrayCapacitanceModels::ALBACH;
273
+ if (!modelsData.is_null() && modelsData.find("strayCapacitance") != modelsData.end()) {
274
+ OpenMagnetics::from_json(modelsData["strayCapacitance"], strayCapacitanceModelName);
275
+ }
276
+
277
+ OpenMagnetics::StrayCapacitance strayCapacitance(strayCapacitanceModelName);
278
+ auto strayCapacitanceOutput = strayCapacitance.calculate_capacitance(coil);
279
+
280
+ json result;
281
+ to_json(result, strayCapacitanceOutput);
282
+ return result;
283
+ }
284
+ catch (const std::exception &exc) {
285
+ json exception;
286
+ exception["data"] = "Exception: " + std::string{exc.what()};
287
+ return exception;
288
+ }
289
+ }
290
+
291
+ json calculate_maxwell_capacitance_matrix(json coilJson, json capacitanceAmongWindingsJson) {
292
+ try {
293
+ OpenMagnetics::Coil coil(coilJson, false);
294
+ auto capacitanceAmongWindings = capacitanceAmongWindingsJson.get<std::map<std::string, std::map<std::string, double>>>();
295
+
296
+ auto maxwellMatrix = OpenMagnetics::StrayCapacitance::calculate_maxwell_capacitance_matrix(coil, capacitanceAmongWindings);
297
+
298
+ json result = json::array();
299
+ for (const auto& matrix : maxwellMatrix) {
300
+ json matrixJson;
301
+ to_json(matrixJson, matrix);
302
+ result.push_back(matrixJson);
303
+ }
304
+ return result;
305
+ }
306
+ catch (const std::exception &exc) {
307
+ json exception;
308
+ exception["data"] = "Exception: " + std::string{exc.what()};
309
+ return exception;
310
+ }
311
+ }
312
+
193
313
  void register_simulation_bindings(py::module& m) {
194
314
  m.def("simulate", &simulate,
195
315
  R"pbdoc(
@@ -304,6 +424,102 @@ void register_simulation_bindings(py::module& m) {
304
424
  Returns:
305
425
  JSON array of column name strings.
306
426
  )pbdoc");
427
+
428
+ m.def("calculate_inductance_matrix", &calculate_inductance_matrix,
429
+ R"pbdoc(
430
+ Calculate the complete inductance matrix for a magnetic component.
431
+
432
+ Computes the inductance matrix at the specified frequency, including
433
+ self inductances (diagonal elements) and mutual inductances (off-diagonal).
434
+
435
+ Args:
436
+ magnetic_json: JSON object containing magnetic component specification.
437
+ frequency: Operating frequency in Hz.
438
+ models_json: JSON object specifying which models to use (e.g., reluctance model).
439
+
440
+ Returns:
441
+ JSON object with the inductance matrix at the specified frequency.
442
+ )pbdoc");
443
+
444
+ m.def("calculate_leakage_inductance", &calculate_leakage_inductance,
445
+ R"pbdoc(
446
+ Calculate leakage inductance between windings.
447
+
448
+ Computes the leakage inductance from a source winding to all other windings.
449
+
450
+ Args:
451
+ magnetic_json: JSON object containing magnetic component specification.
452
+ frequency: Operating frequency in Hz.
453
+ source_index: Index of the source winding (0-based).
454
+
455
+ Returns:
456
+ JSON object with leakage inductance values to each winding.
457
+ )pbdoc");
458
+
459
+ m.def("calculate_dc_resistance_per_winding", &calculate_dc_resistance_per_winding,
460
+ R"pbdoc(
461
+ Calculate DC resistance for each winding.
462
+
463
+ Computes the DC resistance of each winding based on wire properties
464
+ and temperature.
465
+
466
+ Args:
467
+ coil_json: JSON object containing coil specification with turns and wire info.
468
+ temperature: Temperature in degrees Celsius for resistance calculation.
469
+
470
+ Returns:
471
+ JSON array with DC resistance value for each winding in Ohms.
472
+ )pbdoc");
473
+
474
+ m.def("calculate_resistance_matrix", &calculate_resistance_matrix,
475
+ R"pbdoc(
476
+ Calculate the resistance matrix for a magnetic component.
477
+
478
+ Computes the frequency-dependent resistance matrix including self and mutual
479
+ resistances. Uses the Spreen (1990) method with inductance ratio scaling
480
+ for proper mutual resistance calculation.
481
+
482
+ Args:
483
+ magnetic_json: JSON object containing magnetic component specification.
484
+ temperature: Temperature in degrees Celsius for resistance calculation.
485
+ frequency: Operating frequency in Hz.
486
+
487
+ Returns:
488
+ JSON object with resistance matrix (magnitude and frequency).
489
+ )pbdoc");
490
+
491
+ m.def("calculate_stray_capacitance", &calculate_stray_capacitance,
492
+ R"pbdoc(
493
+ Calculate stray capacitance for a coil.
494
+
495
+ Computes turn-to-turn and winding-to-winding capacitances using the
496
+ specified capacitance model.
497
+
498
+ Args:
499
+ coil_json: JSON object containing coil specification with turns.
500
+ operating_point_json: JSON object with operating conditions for voltage distribution.
501
+ models_json: JSON object specifying capacitance model (e.g., "Albach", "Koch").
502
+
503
+ Returns:
504
+ JSON object with capacitance values including capacitance among turns,
505
+ capacitance among windings, and Maxwell capacitance matrix.
506
+ )pbdoc");
507
+
508
+ m.def("calculate_maxwell_capacitance_matrix", &calculate_maxwell_capacitance_matrix,
509
+ R"pbdoc(
510
+ Calculate Maxwell capacitance matrix from inter-winding capacitances.
511
+
512
+ Converts inter-winding capacitance values to the standard Maxwell
513
+ capacitance matrix format used in circuit simulation.
514
+
515
+ Args:
516
+ coil_json: JSON object containing coil specification.
517
+ capacitance_among_windings_json: JSON object with capacitance values
518
+ between each pair of windings.
519
+
520
+ Returns:
521
+ JSON array containing the Maxwell capacitance matrix.
522
+ )pbdoc");
307
523
  }
308
524
 
309
525
  } // namespace PyMKF
@@ -20,6 +20,18 @@ json extract_operating_point(json fileJson, size_t numberWindings, double freque
20
20
  json extract_map_column_names(json fileJson, size_t numberWindings, double frequency);
21
21
  json extract_column_names(json fileJson);
22
22
 
23
+ // Inductance calculations
24
+ json calculate_inductance_matrix(json magneticJson, double frequency, json modelsData);
25
+ json calculate_leakage_inductance(json magneticJson, double frequency, size_t sourceIndex);
26
+
27
+ // Resistance calculations
28
+ json calculate_dc_resistance_per_winding(json coilJson, double temperature);
29
+ json calculate_resistance_matrix(json magneticJson, double temperature, double frequency);
30
+
31
+ // Capacitance calculations
32
+ json calculate_stray_capacitance(json coilJson, json operatingPointJson, json modelsData);
33
+ json calculate_maxwell_capacitance_matrix(json coilJson, json capacitanceAmongWindingsJson);
34
+
23
35
  void register_simulation_bindings(py::module& m);
24
36
 
25
37
  } // namespace PyMKF
File without changes
File without changes