Revert "More Elmer WIP"

This reverts commit 80294f98c2.
This commit is contained in:
jaseg 2024-10-08 16:15:28 +02:00
parent ed9e1d3e53
commit 8577c6209f
5 changed files with 18 additions and 89 deletions

View file

@ -208,14 +208,13 @@ def inductance(mesh_file, sim_dir, solver_method):
fr4 = elmer.load_material('fr4', sim, 'coil_mag_materials.yml')
copper = elmer.load_material('copper', sim, 'coil_mag_materials.yml')
#solver_coil = elmer.load_solver('Coil_Solver', sim, 'coil_mag_solvers.yml')
solver_coil = elmer.load_solver('Coil_Solver', sim, 'coil_mag_solvers.yml')
solver_magdyn = elmer.load_solver('Magneto_Dynamics', sim, 'coil_mag_solvers.yml')
solver_current = elmer.load_solver('Static_Current_Conduction', sim, 'coil_mag_solvers.yml')
if solver_method:
solver_magdyn.data['Linear System Iterative Method'] = solver_method
solver_magdyn_calc = elmer.load_solver('Magneto_Dynamics_Calculations', sim, 'coil_mag_solvers.yml')
copper_eqn = elmer.Equation(sim, 'copperEqn', [solver_current, solver_magdyn, solver_magdyn_calc])
copper_eqn = elmer.Equation(sim, 'copperEqn', [solver_coil, solver_magdyn, solver_magdyn_calc])
air_eqn = elmer.Equation(sim, 'airEqn', [solver_magdyn, solver_magdyn_calc])
bdy_trace = elmer.Body(sim, 'trace', [physical['trace'][1]])
@ -241,29 +240,17 @@ def inductance(mesh_file, sim_dir, solver_method):
comp_coil = elmer.Component(sim, 'Coil', [bdy_trace])
comp_coil.data['Desired Current Density'] = 'Real 1.0'
#current_force = elmer.BodyForce(sim, 'Source', {
# 'Current Density 1': 'Equals "CoilCurrent e 1"',
# 'Current Density 2': 'Equals "CoilCurrent e 2"',
# 'Current Density 3': 'Equals "CoilCurrent e 3"',
# })
potential_force = elmer.BodyForce(sim, 'electric_potential', {'Electric Potential': 'Equals "Potential"'})
bdy_trace.body_force = potential_force
#bdy_trace.body_force = current_force
current_force = elmer.BodyForce(sim, 'Source', {
'Current Density 1': 'Equals "CoilCurrent e 1"',
'Current Density 2': 'Equals "CoilCurrent e 2"',
'Current Density 3': 'Equals "CoilCurrent e 3"',
})
bdy_trace.body_force = current_force
# boundaries
boundary_airbox = elmer.Boundary(sim, 'FarField', [physical['airbox_surface'][1]])
boundary_airbox.data['Electric Infinity BC'] = 'True'
boundary_vplus = elmer.Boundary(sim, 'Vplus', [physical['interface_top'][1]])
#boundary_vplus.data['Coil Start'] = True
#boundary_vplus.data['A re {e}'] = 'Real 0'
boundary_vplus.data['Potential'] = 1.0
boundary_vplus.data['Save Scalars'] = True
boundary_vminus = elmer.Boundary(sim, 'Vminus', [physical['interface_bottom'][1]])
#boundary_vminus.data['Coil End'] = True
boundary_vminus.data['Potential'] = 0.0
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = sim_dir if sim_dir else Path(tmpdir)
@ -304,7 +291,7 @@ def inductance(mesh_file, sim_dir, solver_method):
assert math.isclose(V, 1.0, abs_tol=1e-3)
print(f'Total magnetic field energy: {format_si(U_mag, "J")}')
print(f'Reference coil current: {format_si(I, "A")}')
print(f'Reference coil current: {format_si(I, "Ω")}')
print(f'Coil resistance calculated by solver: {format_si(R, "Ω")}')
print(f'Inductance calucated from field: {format_si(L, "H")}')