From 78f5bf965f1fc92952b749bd2e7422b2b874adcf Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 6 Oct 2023 16:17:25 +0200 Subject: Mesh WIP --- coil_parasitics.py | 8 ++++---- twisted_coil_gen_twolayer.py | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/coil_parasitics.py b/coil_parasitics.py index 5bb7b02..47d5cd2 100644 --- a/coil_parasitics.py +++ b/coil_parasitics.py @@ -73,14 +73,14 @@ def elmer_grid(infile, outfile=None, intype=None, outtype=None, cwd=None, **kwar if outfile is not None: kwargs['out'] = str(outfile) - args = ['ElmerGrid', intype, outtype, infile] + args = ['ElmerGrid', intype, outtype, str(infile)] for key, value in kwargs.items(): args.append(f'-{key}') if isinstance(value, (tuple, list)): args.extend(str(v) for v in value) else: args.append(str(value)) - subprocess.run(args, cwd=cwd) + subprocess.run(args, cwd=cwd, check=True) def elmer_solver(cwd): subprocess.run(['ElmerSolver'], cwd=cwd) @@ -138,7 +138,7 @@ def run_capacitance_simulation(mesh_file, sim_dir): sim.write_startinfo(tmpdir) sim.write_sif(tmpdir) # Convert mesh from gmsh to elemer formats. Also scale it from 1 unit = 1 mm to 1 unit = 1 m (SI units) - elmer_grid(mesh_file.name, 'mesh', cwd=tmpdir, scale=[1e-3, 1e-3, 1e-3]) + elmer_grid(mesh_file.absolute(), 'mesh', cwd=tmpdir, scale=[1e-3, 1e-3, 1e-3]) elmer_solver(tmpdir) capacitance_matrix = np.loadtxt(tmpdir / 'capacitance.txt') @@ -212,7 +212,7 @@ def run_inductance_simulation(mesh_file, sim_dir): sim.write_startinfo(tmpdir) sim.write_sif(tmpdir) # Convert mesh from gmsh to elemer formats. Also scale it from 1 unit = 1 mm to 1 unit = 1 m (SI units) - elmer_grid(mesh_file.name, 'mesh', cwd=tmpdir, scale=[1e-3, 1e-3, 1e-3]) + elmer_grid(mesh_file.absolute(), 'mesh', cwd=tmpdir, scale=[1e-3, 1e-3, 1e-3]) elmer_solver(tmpdir) diff --git a/twisted_coil_gen_twolayer.py b/twisted_coil_gen_twolayer.py index f603cd0..1ecde20 100644 --- a/twisted_coil_gen_twolayer.py +++ b/twisted_coil_gen_twolayer.py @@ -253,6 +253,7 @@ def traces_to_gmsh_mag(traces, mesh_out, bbox, model_name='gerbonara_board', log print('Cutting substrate') occ.cut([(3, substrate)], [(3, toplevel_tag)], removeObject=True, removeTool=False) + occ.fragment([(3, substrate)], [(2, interface_tag_top), (2, interface_tag_bottom)]) occ.fragment([(3, airbox)], [(3, substrate), (3, toplevel_tag)]) print('Synchronizing') @@ -263,6 +264,11 @@ def traces_to_gmsh_mag(traces, mesh_out, bbox, model_name='gerbonara_board', log trace_physical = gmsh.model.add_physical_group(3, [toplevel_tag], name='trace') interface_top_physical = gmsh.model.add_physical_group(2, [interface_tag_top], name='interface_top') interface_bottom_physical = gmsh.model.add_physical_group(2, [interface_tag_bottom], name='interface_bottom') + + print('first disk', first_disk) + print('bbox', occ.getBoundingBox(2, interface_tag_top)) + print('last disk', last_disk) + print('bbox', occ.getBoundingBox(2, interface_tag_bottom)) airbox_adjacent = set(gmsh.model.getAdjacencies(3, airbox)[1]) in_bbox = {tag for _dim, tag in gmsh.model.getEntitiesInBoundingBox(x1+eps, y1+eps, z0+eps, x2-eps, y2-eps, z0+ab_h-eps, dim=2)} -- cgit