Skip to content

Commit

Permalink
add magnetic core transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
otvam committed Jan 7, 2025
1 parent f27ac6d commit 2037559
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/content/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ examples_stl/inductor_toroid

.. image:: ../examples/examples_stl_inductor_toroid.png

examples_stl/transformer_core
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Defined with **STL files**
* **Transformer with two windings and a magnetic core**
* Extraction of the **impedance matrix** from the solution
* Example for the extraction of the impedance matrix: ``run_matrix.py``

.. image:: ../examples/examples_stl_transformer_core.png

examples_stl/transformer_air
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Defined with **STL files**
* **Planar transformer with two windings**
* **Planar air-core transformer with two windings**
* Extraction of the **impedance matrix** from the solution
* Example for the extraction of the impedance matrix: ``run_matrix.py``

Expand Down
Binary file added docs/examples/examples_stl_transformer_core.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions examples/examples_stl/transformer_core/geometry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Definition of a "file_geometry" data.
#
# This file is used by the mesher.
# Definition of the voxel structure.
#
# Thomas Guillod - Dartmouth College
# Mozilla Public License Version 2.0

"mesh_type": "stl"
"data_voxelize":
"param":
"d": [1.0e-3, 1.0e-3, 1.0e-3]
"xyz_min": null
"xyz_max": null
"check": true
"tol": 1.0e-6
"thr": 0.5
"pts": 1
"domain_stl":
"core": [{"scale": 1.0e-3, "offset": [0.0, 0.0, 0.0], "filename": !path "stl/core.stl"}]
"pri_coil": [{"scale": 1.0e-3, "offset": [0.0, 0.0, 0.0], "filename": !path "stl/pri_coil.stl"}]
"pri_src": [{"scale": 1.0e-3, "offset": [0.0, 0.0, 0.0], "filename": !path "stl/pri_src.stl"}]
"pri_sink": [{"scale": 1.0e-3, "offset": [0.0, 0.0, 0.0], "filename": !path "stl/pri_sink.stl"}]
"sec_coil": [{"scale": 1.0e-3, "offset": [0.0, 0.0, 0.0], "filename": !path "stl/sec_coil.stl"}]
"sec_src": [{"scale": 1.0e-3, "offset": [0.0, 0.0, 0.0], "filename": !path "stl/sec_src.stl"}]
"sec_sink": [{"scale": 1.0e-3, "offset": [0.0, 0.0, 0.0], "filename": !path "stl/sec_sink.stl"}]
"data_point":
"check_cloud": true
"filter_cloud": true
"pts_cloud": []
"data_resampling":
"use_reduce": false
"use_resample": false
"resampling_factor": [1, 1, 1]
"data_conflict":
"resolve_rules": true
"resolve_random": false
"conflict_rules":
- {"domain_resolve": ["pri_coil"], "domain_keep": ["pri_src"]}
- {"domain_resolve": ["pri_coil"], "domain_keep": ["pri_sink"]}
- {"domain_resolve": ["sec_coil"], "domain_keep": ["sec_src"]}
- {"domain_resolve": ["sec_coil"], "domain_keep": ["sec_sink"]}
"data_integrity":
"domain_connected":
"pri_conductor": {"domain_group": [["pri_coil"], ["pri_src"], ["pri_sink"]], "connected": true}
"sec_conductor": {"domain_group": [["sec_coil"], ["sec_src"], ["sec_sink"]], "connected": true}
"insulation": {"domain_group": [["pri_coil"], ["sec_coil"], ["core"]], "connected": false}
"domain_adjacent":
"pri_terminal": {"domain_group": [["pri_src"], ["pri_sink"]], "connected": false}
"sec_terminal": {"domain_group": [["sec_src"], ["sec_sink"]], "connected": false}
57 changes: 57 additions & 0 deletions examples/examples_stl/transformer_core/problem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Definition of a "file_problem" data.
#
# This file is used by the solver.
# Definition of the magnetic problem to be solved.
#
# Thomas Guillod - Dartmouth College
# Mozilla Public License Version 2.0

"material_def":
"pri_copper":
"domain_list": ["pri_src", "pri_sink", "pri_coil"]
"material_type": "electric"
"orientation_type": "isotropic"
"var_type": "lumped"
"sec_copper":
"domain_list": ["sec_src", "sec_sink", "sec_coil"]
"material_type": "electric"
"orientation_type": "isotropic"
"var_type": "lumped"
"core":
"domain_list": ["core"]
"material_type": "magnetic"
"orientation_type": "isotropic"
"var_type": "lumped"
"source_def":
"pri_src":
"domain_list": ["pri_src"]
"source_type": "voltage"
"var_type": "lumped"
"pri_sink":
"domain_list": ["pri_sink"]
"source_type": "voltage"
"var_type": "lumped"
"sec_src":
"domain_list": ["sec_src"]
"source_type": "voltage"
"var_type": "lumped"
"sec_sink":
"domain_list": ["sec_sink"]
"source_type": "voltage"
"var_type": "lumped"
"material_val": &material_val
"pri_copper": {"rho_re": 1.75e-8, "rho_im": 0.0}
"sec_copper": {"rho_re": 1.75e-8, "rho_im": 0.0}
"core": { "chi_re": 150.0, "chi_im": 0.0 }
"source_val": &source_val
"pri_src": {"V_re": 1.0, "V_im": 0.0, "Z_re": 1.0e-3, "Z_im": 0.0}
"pri_sink": {"V_re": 0.0, "V_im": 0.0, "Z_re": 1.0e-3, "Z_im": 0.0}
"sec_src": {"V_re": 0.0, "V_im": 0.0, "Z_re": 1.0e+3, "Z_im": 0.0}
"sec_sink": {"V_re": 0.0, "V_im": 0.0, "Z_re": 1.0e+3, "Z_im": 0.0}
"sweep_solver":
"sim_default":
"init": null
"param":
"freq": 100.0e+3
"material_val": *material_val
"source_val": *source_val
Binary file not shown.
86 changes: 86 additions & 0 deletions examples/examples_stl/transformer_core/stl/generate_stl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""
Build the CAD objects and export STL files.
"""

__author__ = "Thomas Guillod"
__copyright__ = "Thomas Guillod - Dartmouth College"
__license__ = "Mozilla Public License Version 2.0"

import sys
import cadquery as cq


def get_cad():
"""
Get the different CAD objects.
"""

coil = cq.Workplane("XY", origin=(0.0, 0.0, -2.5))
coil = coil.moveTo(+14.0, +2.0).rect(10.0, 46.0).extrude(1.0)
coil = coil.moveTo(0.0, -16.0).rect(38.0, 10.0).extrude(1.0)
coil = coil.moveTo(-14.0, 0.0).rect(10.0, 42.0).extrude(1.0)
coil = coil.moveTo(-6.0, +16.0).rect(26.0, 10.0).extrude(1.0)

coil = coil.faces(">Z").workplane()
coil = coil.moveTo(+4.0, +16.0).rect(6.0, 10.0).extrude(1.0)

coil = coil.faces(">Z").workplane()
coil = coil.moveTo(+10.0, +16.0).rect(18.0, 10.0).extrude(1.0)
coil = coil.moveTo(+14.0, 0.0).rect(10.0, 42.0).extrude(1.0)
coil = coil.moveTo(0.0, -16.0).rect(38.0, 10.0).extrude(1.0)
coil = coil.moveTo(-14.0, 0.0).rect(10.0, 42.0).extrude(1.0)
coil = coil.moveTo(-10.0, +16.0).rect(18.0, 10.0).extrude(1.0)

coil = coil.faces(">Z").workplane()
coil = coil.moveTo(-4.0, +16.0).rect(6.0, 10.0).extrude(1.0)

coil = coil.faces(">Z").workplane()
coil = coil.moveTo(+6.0, +16.0).rect(26.0, 10.0).extrude(1.0)
coil = coil.moveTo(+14.0, 0.0).rect(10.0, 42.0).extrude(1.0)
coil = coil.moveTo(0.0, -16.0).rect(38.0, 10.0).extrude(1.0)
coil = coil.moveTo(-14.0, +2.0).rect(10.0, 46.0).extrude(1.0)

core = cq.Workplane("XZ")
core = core.moveTo(0.0, 0.0).box(52.0, 19.0, 16.0)
core = core.moveTo(0.0, 0.0).rect(28.0, 9.0).cutThruAll()

src = cq.Workplane("XY").moveTo(+14.0, +25.5).rect(10.0, 1.0).extrude(1.0)
sink = cq.Workplane("XY").moveTo(-14.0, +25.5).rect(10.0, 1.0).extrude(1.0)
src = src.translate((0.0, 0.0, -2.5))
sink = sink.translate((0.0, 0.0, +1.5))

cad_dict = {
"core": core,
"pri_coil": coil.translate((+20.0, 0.0, 0.0)),
"pri_src": src.translate((+20.0, 0.0, 0.0)),
"pri_sink": sink.translate((+20.0, 0.0, 0.0)),
"sec_coil": coil.mirror(mirrorPlane="XY").translate((-20.0, 0.0, 0.0)),
"sec_src": src.mirror(mirrorPlane="XY").translate((-20.0, 0.0, 0.0)),
"sec_sink": sink.mirror(mirrorPlane="XY").translate((-20.0, 0.0, 0.0)),
}

return cad_dict


def write_cad(cad_dict, tol):
"""
Export CAD objects to STL files.
"""

for tag, cad in cad_dict.items():
if cad is not None:
cad.val().exportStl("%s.stl" % tag, tolerance=tol)


if __name__ == "__main__":
# get the object tolerance
tol = 1e-3

# get the CAD objects
cad_dict = get_cad()

# save STL/STEP files
write_cad(cad_dict, tol)

# exit
sys.exit(0)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 2037559

Please sign in to comment.