Work on Elmer sims
This commit is contained in:
parent
63a0b24c81
commit
cb81979a7f
3 changed files with 34 additions and 13 deletions
|
|
@ -1,3 +1,21 @@
|
||||||
|
Coil_Solver:
|
||||||
|
Equation: CoilSolver
|
||||||
|
Procedure: '"CoilSolver" "CoilSolver"'
|
||||||
|
Linear System Solver: Iterative
|
||||||
|
Linear System Preconditioning: ILU1
|
||||||
|
Linear System Max Iterations: 1000
|
||||||
|
Linear System Convergence Tolerance: 1e-10
|
||||||
|
Linear System Iterative Method: BiCGStab
|
||||||
|
Linear System Residual Output: 10
|
||||||
|
Steady State Convergence Tolerance: 1e-06
|
||||||
|
Normalize Coil Current: True
|
||||||
|
Nonlinear System Consistent Norm: True
|
||||||
|
Coil Closed: True
|
||||||
|
Narrow Interface: True
|
||||||
|
Save Coil Set: True
|
||||||
|
Save Coil Index: True
|
||||||
|
Calculate Elemental Fields: True
|
||||||
|
|
||||||
Static_Current_Conduction:
|
Static_Current_Conduction:
|
||||||
Equation: Static Current Conduction
|
Equation: Static Current Conduction
|
||||||
Variable: Potential
|
Variable: Potential
|
||||||
|
|
|
||||||
|
|
@ -208,13 +208,13 @@ def inductance(mesh_file, sim_dir, solver_method):
|
||||||
fr4 = elmer.load_material('fr4', sim, 'coil_mag_materials.yml')
|
fr4 = elmer.load_material('fr4', sim, 'coil_mag_materials.yml')
|
||||||
copper = elmer.load_material('copper', sim, 'coil_mag_materials.yml')
|
copper = elmer.load_material('copper', sim, 'coil_mag_materials.yml')
|
||||||
|
|
||||||
solver_current = elmer.load_solver('Static_Current_Conduction', 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_magdyn = elmer.load_solver('Magneto_Dynamics', sim, 'coil_mag_solvers.yml')
|
||||||
if solver_method:
|
if solver_method:
|
||||||
solver_magdyn.data['Linear System Iterative Method'] = 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')
|
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])
|
air_eqn = elmer.Equation(sim, 'airEqn', [solver_magdyn, solver_magdyn_calc])
|
||||||
|
|
||||||
bdy_trace = elmer.Body(sim, 'trace', [physical['trace'][1]])
|
bdy_trace = elmer.Body(sim, 'trace', [physical['trace'][1]])
|
||||||
|
|
@ -237,20 +237,20 @@ def inductance(mesh_file, sim_dir, solver_method):
|
||||||
bdy_if_bottom.material = copper
|
bdy_if_bottom.material = copper
|
||||||
bdy_if_bottom.equation = copper_eqn
|
bdy_if_bottom.equation = copper_eqn
|
||||||
|
|
||||||
potential_force = elmer.BodyForce(sim, 'electric_potential', {'Electric Potential': 'Equals "Potential"'})
|
comp_coil = elmer.Component(sim, 'Coil', [bdy_trace])
|
||||||
bdy_trace.body_force = potential_force
|
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"',
|
||||||
|
})
|
||||||
|
bdy_trace.body_force = current_force
|
||||||
|
|
||||||
# boundaries
|
# boundaries
|
||||||
boundary_airbox = elmer.Boundary(sim, 'FarField', [physical['airbox_surface'][1]])
|
boundary_airbox = elmer.Boundary(sim, 'FarField', [physical['airbox_surface'][1]])
|
||||||
boundary_airbox.data['Electric Infinity BC'] = 'True'
|
boundary_airbox.data['Electric Infinity BC'] = 'True'
|
||||||
|
|
||||||
boundary_vplus = elmer.Boundary(sim, 'Vplus', [physical['interface_top'][1]])
|
|
||||||
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['Potential'] = 0.0
|
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
tmpdir = sim_dir if sim_dir else Path(tmpdir)
|
tmpdir = sim_dir if sim_dir else Path(tmpdir)
|
||||||
|
|
||||||
|
|
@ -261,6 +261,8 @@ def inductance(mesh_file, sim_dir, solver_method):
|
||||||
stdout_log=(tmpdir / 'ElmerGrid_stdout.log'),
|
stdout_log=(tmpdir / 'ElmerGrid_stdout.log'),
|
||||||
stderr_log=(tmpdir / 'ElmerGrid_stderr.log'))
|
stderr_log=(tmpdir / 'ElmerGrid_stderr.log'))
|
||||||
solver_stdout, solver_stderr = (tmpdir / 'ElmerSolver_stdout.log'), (tmpdir / 'ElmerSolver_stderr.log')
|
solver_stdout, solver_stderr = (tmpdir / 'ElmerSolver_stdout.log'), (tmpdir / 'ElmerSolver_stderr.log')
|
||||||
|
print('Solver stdout:', solver_stdout)
|
||||||
|
print('Solver stderr:', solver_stderr)
|
||||||
res = elmer_solver(tmpdir,
|
res = elmer_solver(tmpdir,
|
||||||
stdout_log=solver_stdout,
|
stdout_log=solver_stdout,
|
||||||
stderr_log=solver_stderr)
|
stderr_log=solver_stderr)
|
||||||
|
|
|
||||||
|
|
@ -616,6 +616,7 @@ def print_valid_twists(ctx, param, value):
|
||||||
@click.option('--twists', type=int, default=1, help='Number of twists per revolution. Note that this number must be co-prime to the number of turns. Run with --show-twists to list valid values. (default: 1)')
|
@click.option('--twists', type=int, default=1, help='Number of twists per revolution. Note that this number must be co-prime to the number of turns. Run with --show-twists to list valid values. (default: 1)')
|
||||||
@click.option('--circle-segments', type=int, default=64, help='When not using arcs, the number of points to use for arc interpolation per 360 degrees.')
|
@click.option('--circle-segments', type=int, default=64, help='When not using arcs, the number of points to use for arc interpolation per 360 degrees.')
|
||||||
@click.option('--show-twists', callback=print_valid_twists, expose_value=False, type=int, is_eager=True, help='Calculate and show valid --twists counts for the given number of turns. Takes the number of turns as a value.')
|
@click.option('--show-twists', callback=print_valid_twists, expose_value=False, type=int, is_eager=True, help='Calculate and show valid --twists counts for the given number of turns. Takes the number of turns as a value.')
|
||||||
|
@click.option('--close-loop', is_flag=True, help='Close coil loop for simulation meshes')
|
||||||
@click.option('--clearance', type=float, default=None)
|
@click.option('--clearance', type=float, default=None)
|
||||||
@click.option('--arc-tolerance', type=float, default=0.02)
|
@click.option('--arc-tolerance', type=float, default=0.02)
|
||||||
@click.option('--mesh-split-out', type=click.Path(writable=True, dir_okay=False, path_type=Path))
|
@click.option('--mesh-split-out', type=click.Path(writable=True, dir_okay=False, path_type=Path))
|
||||||
|
|
@ -633,7 +634,7 @@ def generate(outfile, turns, outer_diameter, inner_diameter, via_diameter, via_d
|
||||||
footprint_name, layer_pair, twists, clipboard, counter_clockwise, keepout_zone, keepout_margin,
|
footprint_name, layer_pair, twists, clipboard, counter_clockwise, keepout_zone, keepout_margin,
|
||||||
arc_tolerance, pcb, mesh_out, magneticalc_out, circle_segments, mesh_split_out, copper_thickness,
|
arc_tolerance, pcb, mesh_out, magneticalc_out, circle_segments, mesh_split_out, copper_thickness,
|
||||||
board_thickness, mesh_mutual_out, mutual_offset_x, mutual_offset_y, mutual_offset_z, mutual_rotation_z,
|
board_thickness, mesh_mutual_out, mutual_offset_x, mutual_offset_y, mutual_offset_z, mutual_rotation_z,
|
||||||
two_layer):
|
two_layer, close_loop):
|
||||||
|
|
||||||
if 'WAYLAND_DISPLAY' in os.environ:
|
if 'WAYLAND_DISPLAY' in os.environ:
|
||||||
copy, paste, cliputil = ['wl-copy'], ['wl-paste'], 'xclip'
|
copy, paste, cliputil = ['wl-copy'], ['wl-paste'], 'xclip'
|
||||||
|
|
@ -881,7 +882,7 @@ def generate(outfile, turns, outer_diameter, inner_diameter, via_diameter, via_d
|
||||||
svg_vias.append(Tag('circle', cx=xv, cy=yv, r=via_diameter/2, stroke='none', fill='white'))
|
svg_vias.append(Tag('circle', cx=xv, cy=yv, r=via_diameter/2, stroke='none', fill='white'))
|
||||||
svg_vias.append(Tag('circle', cx=xv, cy=yv, r=via_drill/2, stroke='none', fill='black'))
|
svg_vias.append(Tag('circle', cx=xv, cy=yv, r=via_drill/2, stroke='none', fill='black'))
|
||||||
|
|
||||||
if i > 0:
|
if i > 0 or close_loop:
|
||||||
xv, yv = outer_via_ring_radius*cos(start_angle), outer_via_ring_radius*sin(start_angle)
|
xv, yv = outer_via_ring_radius*cos(start_angle), outer_via_ring_radius*sin(start_angle)
|
||||||
pads.append(make_via(xv, yv, layer_pair))
|
pads.append(make_via(xv, yv, layer_pair))
|
||||||
if not isclose(via_offset, 0, abs_tol=1e-6):
|
if not isclose(via_offset, 0, abs_tol=1e-6):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue