From 2d4c40c0f79319a96cc68a484bf82059313b827b Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 11 Oct 2023 17:06:42 +0200 Subject: Get self capacitance simulation to work --- coil_mag_solvers.yml | 3 +- coil_parasitics.py | 12 ++- self-capacitance-actually-working.sif | 173 ++++++++++++++++++++++++++++++++++ self-capacitance-working.sif | 154 ++++++++++++++++++++++++++++++ 4 files changed, 340 insertions(+), 2 deletions(-) create mode 100644 self-capacitance-actually-working.sif create mode 100644 self-capacitance-working.sif diff --git a/coil_mag_solvers.yml b/coil_mag_solvers.yml index deee8e9..704a8dd 100644 --- a/coil_mag_solvers.yml +++ b/coil_mag_solvers.yml @@ -31,6 +31,7 @@ Magneto_Dynamics: Linear System Max Iterations: 5000 Linear System Iterative Method: TFQMR BiCGStabL Polynomial Degree: 4 + "Jfix: Linear System Max Iterations": 5000 Idrs Parameter: 6 Solver Timing: True @@ -41,7 +42,7 @@ Magneto_Dynamics_Calculations: Calculate Magnetic Field Strength: True Calculate JxB: False Calculate Current Density: True - Calculate Electric Field: False + Calculate Electric Field: True Calculate Nodal Fields: False Calculate Elemental Fields: True Linear System Solver: Iterative diff --git a/coil_parasitics.py b/coil_parasitics.py index 0eddf6f..46552c7 100644 --- a/coil_parasitics.py +++ b/coil_parasitics.py @@ -147,14 +147,21 @@ def self_capacitance(mesh_file, sim_dir): bdy_ab.material = air bdy_ab.equation = eqn + max_num = -1 + # boundaries for name, identity in physical.items(): if (m := re.fullmatch(r'trace([0-9]+)', name)): num = int(m.group(1)) + max_num = max(num, max_num) bndry_m2 = elmer.Boundary(sim, name, [identity[1]]) bndry_m2.data['Capacitance Body'] = str(num) + if (tr := physical.get('trace')): + bndry_m2 = elmer.Boundary(sim, 'trace', [tr[1]]) + bndry_m2.data['Capacitance Body'] = f'{max_num+1}' + boundary_airbox = elmer.Boundary(sim, 'FarField', [physical['airbox_surface'][1]]) boundary_airbox.data['Electric Infinity BC'] = 'True' @@ -175,8 +182,9 @@ def self_capacitance(mesh_file, sim_dir): @cli.command() @click.option('-d', '--sim-dir', type=click.Path(dir_okay=True, file_okay=False, path_type=Path)) +@click.option('--solver-method') @click.argument('mesh_file', type=click.Path(dir_okay=False, path_type=Path)) -def inductance(mesh_file, sim_dir): +def inductance(mesh_file, sim_dir, solver_method): physical = dict(enumerate_mesh_bodies(mesh_file)) if sim_dir is not None: @@ -199,6 +207,8 @@ def inductance(mesh_file, sim_dir): solver_current = elmer.load_solver('Static_Current_Conduction', sim, 'coil_mag_solvers.yml') solver_magdyn = elmer.load_solver('Magneto_Dynamics', 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]) diff --git a/self-capacitance-actually-working.sif b/self-capacitance-actually-working.sif new file mode 100644 index 0000000..5f7423f --- /dev/null +++ b/self-capacitance-actually-working.sif @@ -0,0 +1,173 @@ +Header + CHECK KEYWORDS "Warn" + Mesh DB "." "mesh" +End + +Simulation + 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 +End + +Constants + Stefan Boltzmann = 5.6704e-08 + Permittivity of Vacuum = 8.8541878128e-12 + Gravity(4) = 0 -1 0 9.80665 + Boltzmann Constant = 1.380649e-23 + Unit Charge = 1.602176634e-19 +End + +! airEqn +Equation 1 + Active Solvers(1) = 2 +End + +! copperEqn +Equation 2 + Active Solvers(1) = 1 2 +End + +Solver 1 + Equation = Static Current Conduction + Variable = Potential + 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 +End + +Solver 2 + Equation = Electrostatics + Procedure = "StatElecSolve" "StatElecSolver" + Variable = PotentialStat + Calculate Electric Field = 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 = 500 + 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 +End + + + +! air +Material 1 + Density = 1.1885 + Electric Conductivity = 0.0 + Heat Capacity = 1006.4 + Heat Conductivity = 0.025873 + Relative Permeability = 1 + Relative Permittivity = 1 +End + +! ro4003c +Material 2 + Density = 1790 + Electric Conductivity = 0.0 + Relative Permeability = 1 + Relative Permittivity = 3.55 +End + +! copper +Material 3 + Density = 8960.0 + Electric Conductivity = 59600000 + Emissivity = 0.012 + Heat Capacity = 415.0 + Heat Conductivity = 401.0 + Relative Permeability = 1 +End + +! trace +Body 1 + Target Bodies(1) = 3 + Equation = 2 ! copperEqn + Material = 3 ! copper + Body Force = 1 ! electric_potential +End + +! substrate +Body 2 + Target Bodies(1) = 1 + Equation = 1 ! airEqn + Material = 2 ! ro4003c +End + +! airbox +Body 3 + Target Bodies(1) = 2 + Equation = 1 ! airEqn + Material = 1 ! air + Body Force = 1 +End + +! interface_top +Body 4 + Target Bodies(1) = 4 + Material = 3 ! copper +End + +! interface_bottom +Body 5 + Target Bodies(1) = 5 + Material = 3 ! copper +End + + +! FarField +Boundary Condition 1 + Target Boundaries(1) = 6 + Electric Infinity BC = True +End + +! Vplus +Boundary Condition 2 + Target Boundaries(1) = 4 + Potential = 1.0 + Save Scalars = True +End + +! Vminus +Boundary Condition 3 + Target Boundaries(1) = 5 + Potential = 0.0 +End + + +! electric_potential +Body Force 1 + PotentialStat = Equals "Potential" +End + diff --git a/self-capacitance-working.sif b/self-capacitance-working.sif new file mode 100644 index 0000000..e7691df --- /dev/null +++ b/self-capacitance-working.sif @@ -0,0 +1,154 @@ +Header + CHECK KEYWORDS "Warn" + Mesh DB "." "mesh" +End + +Simulation + 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 +End + +Constants + Stefan Boltzmann = 5.6704e-08 + Permittivity of Vacuum = 8.8541878128e-12 + Gravity(4) = 0 -1 0 9.80665 + Boltzmann Constant = 1.380649e-23 + Unit Charge = 1.602176634e-19 +End + +! airEqn +Equation 1 + Active Solvers(1) = 1 ! Static_Current_Conduction, Magneto_Dynamics, Magneto_Dynamics_Calculations, +End + +! Static_Current_Conduction +Solver 1 + Equation = Electrostatics + Procedure = "StatElecSolve" "StatElecSolver" + Variable = Potential + Calculate Electric Field = True + Calculate Electric Energy = True + Exec Solver = Always + Stabilize = True + Bubbles = False + Lumped Mass Matrix = False + Optimize Bandwidth = 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 = 500 + Linear System Convergence Tolerance = 1e-10 + BiCGstabl polynomial degree = 2 + Linear System Preconditioning = ILU0 + Linear System ILUT Tolerance = 0.001 + Linear System Abort Not Converged = False + Linear System Residual Output = 10 + Linear System Precondition Recompute = 1 +End + + +! air +Material 1 + Density = 1.1885 + Electric Conductivity = 0.0 + Heat Capacity = 1006.4 + Heat Conductivity = 0.025873 + Relative Permeability = 1 + Relative Permittivity = 1 +End + +! ro4003c +Material 2 + Density = 1790 + Electric Conductivity = 0.0 + Relative Permeability = 1 + Relative Permittivity = 3.55 +End + +! copper +Material 3 + Density = 8960.0 + Electric Conductivity = 59600000 + Emissivity = 0.012 + Heat Capacity = 415.0 + Heat Conductivity = 401.0 + Relative Permeability = 1 +End + +! trace +Body 1 + Target Bodies(1) = 3 + Material = 3 ! copper + Body Force = 1 ! electric_potential +End + +! substrate +Body 2 + Target Bodies(1) = 1 + Equation = 1 ! airEqn + Material = 2 ! ro4003c +End + +! airbox +Body 3 + Target Bodies(1) = 2 + Equation = 1 ! airEqn + Material = 1 ! air +End + +! interface_top +Body 4 + Target Bodies(1) = 4 + Material = 3 ! copper +End + +! interface_bottom +Body 5 + Target Bodies(1) = 5 + Material = 3 ! copper +End + + +! FarField +Boundary Condition 1 + Target Boundaries(1) = 6 + Electric Infinity BC = True +End + +! Vplus +Boundary Condition 2 + Target Boundaries(1) = 4 + Potential = 1.0 + Save Scalars = True +End + +! Vminus +Boundary Condition 3 + Target Boundaries(1) = 5 + Potential = 0.0 +End + + +! electric_potential +Body Force 1 + Electric Potential = Equals "Potential" +End + + + -- cgit