Created
May 30, 2023 16:47
-
-
Save blakseth/81d520a087630aa4a81f9ef9aeb31831 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import netgen.occ as occ | |
from netgen.webgui import Draw as GeoDraw | |
import numpy as np | |
import ngsolve as ng | |
from ngsolve.webgui import Draw | |
tube_axes = occ.Axes(occ.Pnt(0,0,0), occ.Z) | |
tube_radius = 10 | |
spiral_spacing = 2.1 | |
spiral_width = 5 | |
spiral_thickness = 0.8 | |
revs = 2.02 # NOT okay | |
#revs = 2.01 # Okay | |
angle = revs*2*np.pi | |
L = revs*(spiral_thickness + spiral_spacing) + spiral_thickness | |
cyl1 = occ.Cylinder(tube_axes, tube_radius, L).faces[0] | |
cyl2 = occ.Cylinder(tube_axes, tube_radius + spiral_width, L).faces[0] | |
seg1 = occ.Segment(occ.Pnt(0, 0), occ.Pnt(angle, L-spiral_thickness)) | |
seg2 = occ.Segment(occ.Pnt(angle, L-spiral_thickness), occ.Pnt(angle, L)) | |
seg3 = occ.Segment(occ.Pnt(angle, L), occ.Pnt(0, spiral_thickness)) | |
seg4 = occ.Segment(occ.Pnt(0, spiral_thickness), occ.Pnt(0, 0)) | |
arc1 = occ.Edge(seg1, cyl1) | |
arc2 = occ.Edge(seg2, cyl1) | |
arc3 = occ.Edge(seg3, cyl1) | |
arc4 = occ.Edge(seg4, cyl1) | |
arc5 = occ.Edge(seg1, cyl2) | |
arc6 = occ.Edge(seg2, cyl2) | |
arc7 = occ.Edge(seg3, cyl2) | |
arc8 = occ.Edge(seg4, cyl2) | |
wire1 = occ.Wire([arc1, arc2, arc3, arc4]) | |
wire2 = occ.Wire([arc5, arc6, arc7, arc8]) | |
spiral = occ.ThruSections([wire1, wire2]) | |
geo = occ.OCCGeometry(spiral) | |
cut = occ.Box(occ.Pnt(tube_radius + 0.5*spiral_width, 1, -1), occ.Pnt(tube_radius + spiral_width+1, 2, L+1)) | |
cut_spiral = spiral - cut | |
GeoDraw(cut_spiral) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment