More Elmer WIP

This commit is contained in:
jaseg 2024-09-23 19:25:11 +02:00
parent 70d37e1950
commit 80294f98c2
5 changed files with 89 additions and 18 deletions

View file

@ -836,7 +836,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.5"
}
},
"nbformat": 4,

View file

@ -2,18 +2,18 @@ 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 Preconditioning: ILU3
Linear System Max Iterations: 25000
Linear System Convergence Tolerance: 1e-6
Linear System Iterative Method: BiCGStab
Linear System Residual Output: 10
Linear System Residual Output: 1
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
Coil Closed: False
Narrow Interface: 'Logical True'
Save Coil Set: 'Logical True'
Save Coil Index: 'Logical True'
Calculate Elemental Fields: True
Static_Current_Conduction:

View file

@ -208,13 +208,14 @@ 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_coil, solver_magdyn, solver_magdyn_calc])
copper_eqn = elmer.Equation(sim, 'copperEqn', [solver_current, 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]])
@ -240,17 +241,29 @@ 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"',
})
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"',
# })
potential_force = elmer.BodyForce(sim, 'electric_potential', {'Electric Potential': 'Equals "Potential"'})
bdy_trace.body_force = potential_force
#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)
@ -291,7 +304,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, "Ω")}')
print(f'Reference coil current: {format_si(I, "A")}')
print(f'Coil resistance calculated by solver: {format_si(R, "Ω")}')
print(f'Inductance calucated from field: {format_si(L, "H")}')

14
self_capacitance_sim.yml Normal file
View file

@ -0,0 +1,14 @@
3D_steady:
Mesh Levels: 1
Max Output Level: 7
Coordinate System: Cartesian
Coordinate Mapping(3): 1 2 3
Simulation Type: Steady state
Steady State Max Iterations: 1
Output Intervals: 1
Timestepping Method: BDF
Simulation Timing: True
BDF Order: 1
Solver Input File: case.sif
Post File: case.vtu
Output File: case.result

View file

@ -0,0 +1,44 @@
StaticCurrent:
Equation: Static Current Conduction
Variable: PotentialStat
Variable DOFs: 1
Procedure: '"StatCurrentSolve" "StatCurrentSolver"'
Calculate Volume Current: True
Calculate Joule Heating: False
Optimize Bandwidth: True
Nonlinear System Max Iterations: 1
Linear System Solver: Iterative
Linear System Iterative Method: CG
Linear System Max Iterations: 10000
Linear System Convergence Tolerance: 1e-10
Linear System Preconditioning: ILU3
Linear System ILUT Tolerance: 0.001
Linear System Abort Not Converged: False
Linear System Residual Output: 20
Linear System Precondition Recompute: 1
Electrostatics:
Equation: Electrostatics
Procedure: '"StatElecSolve" "StatElecSolver"'
Variable: Potential
Variable DOFs: 1
Calculate Electric Field: True
Calculate Electric Flux: True
Calculate Electric Energy: True
Steady State Convergence Tolerance: 1e-05
Nonlinear System Convergence Tolerance: 1e-07
Nonlinear System Max Iterations: 20
Nonlinear System Newton After Iterations: 3
Nonlinear System Newton After Tolerance: 0.001
Nonlinear System Relaxation Factor: 1
Linear System Solver: Iterative
Linear System Iterative Method: BiCGStab
Linear System Max Iterations: 5000
Linear System Convergence Tolerance: 1e-10
BiCGstabl polynomial degree: 2
Linear System Preconditioning: none
Linear System ILUT Tolerance: 0.001
Linear System Abort Not Converged: False
Linear System Residual Output: 10
Potential Difference: 1.0