"""Siphon pump after Kraus, US 2,783,715 (1957): cylinder 1 with end walls 2, 3 and their annular projections 10, 11;
guide tube 6 as piston rod, piston disks 7, 8 holding packing ring 9; plug 12 with pyramid top 14 and cone 15 at the
tube's outer end, passages 13 above it, stops 17; gate valve 18 (packing 20) screwed to 19 (annular passage 23, outlet 24).
EVERY size OURS (mm, z up, the inlet at the top). Acrylic tube 40/34, stainless tube 10 x 1, O-rings, PETG prints.
Run: xvfb-run -a freecad <wrapper exec'ing this>; NOSAVE=1 for the clash check only. Log: out/build.log"""
import os, math
import FreeCAD as App, Part
V = App.Vector
OUT = "/home/admiraloom/Desktop/youblob/JIRA-tasks/freecad/batch-2540/out/"
LOG = open(OUT + "build.log", "w")
def L(*a): LOG.write(" ".join(map(str, a)) + "\n"); LOG.flush()
def zc(r, z0, z1): return Part.makeCylinder(r, z1 - z0, V(0, 0, z0), V(0, 0, 1))
def ring(ro, ri, z0, z1): return zc(ro, z0, z1).cut(zc(ri, z0 - 1, z1 + 1))
def cone(r0, r1, z0, z1): return Part.makeCone(r0, r1, z1 - z0, V(0, 0, z0), V(0, 0, 1))
def thread(r_major, length, z0, depth, P):
helix = Part.makeHelix(P, length, r_major - depth)
tri = Part.makePolygon([V(r_major - depth - 0.01, 0, -P * 0.42), V(r_major, 0, -0.04), V(r_major, 0, 0.04),
V(r_major - depth - 0.01, 0, P * 0.42), V(r_major - depth - 0.01, 0, -P * 0.42)])
ps = Part.BRepOffsetAPI.MakePipeShell(Part.Wire(helix))
ps.setAuxiliarySpine(Part.Wire(Part.makeLine(V(0, 0, 0), V(0, 0, length))), False, False)
ps.add(tri); ps.build(); ps.makeSolid()
return ps.shape().translate(V(0, 0, z0))
def gland(r_root, z, w, r_out): # outward-facing O-ring groove (on a spigot or plug), root radius r_root
return ring(r_out + 1, r_root, z - w / 2, z + w / 2)
# ---- sizes (ours) ---------------------------------------------------------------------------------------------
CO, CI, LC = 20.0, 17.0, 150.0 # acrylic cylinder 40/34 x 150
SP_R, SP_H = 16.9, 12.0 # cap spigot 33.8 across, 12 long
RING_RI, RING_H = 15.5, 5.0 # annular projections 10, 11: 34 -> 31 across, 5 high
TO, TI = 5.0, 4.0 # stainless guide tube 10 x 1
L6 = 190.0 # guide tube length
DISK_R, DISK_T, HUB_R = 15.0, 4.0, 13.9 # piston disks 30 across, 4 thick; packing seat 27.8 across (O-ring 27 x 3.5)
SEAT = 4.6 # packing seat width between the disks
HOLE_Z, HOLE_R = 9.0, 2.0 # passages 13: three 4 mm holes, centres 9 mm above the tube end
P_TH, R_TH, D_TH = 2.0, 12.0, 1.1 # valve thread: 24 mm major, 2 mm pitch
TRAVEL = 11.8 # valve travel, closed -> open (the cone meets the stops)
BORE_L = 13.4 # part 19's straight bore below its thread: sets where the cone meets the stops
Z_TOP = LC - SP_H - RING_H # 133: top ring underside = highest packing position
Z_BOT = SP_H + RING_H # 17: bottom ring top = lowest packing position
PIST_TOP_UP = Z_TOP + DISK_T # piston (tube) top when the packing meets the top ring
PIST_TOP_DN = Z_BOT + DISK_T + SEAT # packing on the bottom ring
STROKE = PIST_TOP_UP - PIST_TOP_DN
# ---- parts ------------------------------------------------------------------------------------------------------
cyl = ring(CO, CI, 0, LC)
def cap(top):
c = zc(CO, -5, 0).fuse(zc(SP_R, 0, SP_H)).fuse(ring(SP_R, RING_RI, SP_H, SP_H + RING_H))
c = c.cut(gland(15.0, 6.0, 3.2, SP_R)) # O-ring 30 x 2.5 against the 34 bore
if top:
barb = zc(5.0, -25, -5).fuse(cone(5.75, 5.0, -21, -16)).fuse(cone(5.75, 5.0, -14, -9))
c = c.fuse(barb).cut(zc(3.25, -26, SP_H + 1)) # inlet 4: barb for 3/8 in (9.5 mm) tubing, 6.5 bore
c = c.mirror(V(0, 0, 0), V(0, 0, 1)).translate(V(0, 0, LC))
else:
c = c.cut(zc(5.5, -6, SP_H + 1)) # opening 5: 11 across, play for the 10 mm tube
return c
cap_bot, cap_top = cap(False), cap(True)
def piston_parts(zt): # zt = tube top
upper = zc(DISK_R, zt - DISK_T, zt).cut(zc(TO + 0.05, zt - 10, zt + 1)) # disk 7
lower = zc(DISK_R, zt - 2 * DISK_T - SEAT, zt - DISK_T - SEAT).fuse(zc(HUB_R, zt - DISK_T - SEAT, zt - DISK_T))
lower = lower.cut(zc(TO + 0.05, zt - 20, zt + 1)) # disk 8 + seat
gs = [Part.makeCylinder(1.25, DISK_R, V(TO - 0.5, 0, zt - DISK_T / 2), V(1, 0, 0)),
Part.makeCylinder(1.25, DISK_R, V(TO - 0.5, 0, zt - 1.5 * DISK_T - SEAT), V(1, 0, 0))]
return upper.cut(gs[0]), lower.cut(gs[1])
def tube(zt):
t = ring(TO, TI, zt - L6, zt)
ze = zt - L6
for i in range(3):
h = Part.makeCylinder(HOLE_R, 3, V(TI - 1, 0, ze + HOLE_Z), V(1, 0, 0)); h.rotate(V(0, 0, 0), V(0, 0, 1), 120 * i)
t = t.cut(h)
return t
def plug(ze):
p = zc(TI - 0.05, ze, ze + 6).cut(gland(2.7, ze + 3, 2.0, TI)) # stem, O-ring 5 x 1.5
pyr = Part.makePolygon([V((TI - 0.3) * math.cos(math.radians(120 * i + 60)), (TI - 0.3) * math.sin(math.radians(120 * i + 60)), ze + 6) for i in range(3)] +
[V((TI - 0.3) * math.cos(math.radians(60)), (TI - 0.3) * math.sin(math.radians(60)), ze + 6)])
p = p.fuse(Part.Face(pyr).extrude(V(0, 0, 0.01)).fuse(Part.makeCone(TI - 0.3, 0.01, 7, V(0, 0, ze + 6), V(0, 0, 1)).common(
Part.Face(pyr).extrude(V(0, 0, 8))))) # pyramid 14, faces toward 13
p = p.fuse(zc(6.0, ze - 3, ze)).fuse(Part.makeCone(6.0, 0.4, 10, V(0, 0, ze - 3), V(0, 0, -1))) # collar, cone 15
for i in range(3): # stops 17
lug = Part.makeBox(3.5, 4, 3, V(5.5, -2, ze - 3)); lug.rotate(V(0, 0, 0), V(0, 0, 1), 120 * i); p = p.fuse(lug)
return p.removeSplitter()
def grip(b): # gate valve part 18, its bottom face at z = b
g = zc(15.0, b + 10, b + 32).fuse(zc(R_TH - D_TH, b, b + 10)).fuse(thread(R_TH, 9, b + 0.5, D_TH, P_TH))
g = g.cut(zc(TO + 0.1, b - 1, b + 33))
for z in (b + 3.5, b + 14.5): # packing 20: O-rings 10 x 1.5 in the bore
g = g.cut(ring(6.25, TO, z - 1.0, z + 1.0))
for i in range(24): # finger flutes
f = Part.makeCylinder(1.2, 20, V(15.3, 0, b + 11), V(0, 0, 1)); f.rotate(V(0, 0, 0), V(0, 0, 1), 15 * i); g = g.cut(f)
return g
def shell(b): # part 19: female thread, space 23, cone, outlet 24
c0 = b - BORE_L
s = zc(15.0, c0, b + 10).fuse(Part.makeCone(15.0, 7.0, 10, V(0, 0, c0), V(0, 0, -1)))
s = s.fuse(zc(5.0, b - 45, c0 - 9.9)).fuse(cone(5.75, 5.0, b - 41, b - 36)).fuse(cone(5.75, 5.0, b - 34, b - 29))
s = s.cut(zc(R_TH - D_TH + 0.25, b, b + 10.1)).cut(thread(R_TH + 0.25, 13, b + 0.5 - 2 * P_TH, D_TH + 0.25, P_TH)) # in phase with 18
s = s.cut(zc(10.0, c0, b + 0.01)).cut(Part.makeCone(10.0, 4.0, 10, V(0, 0, c0), V(0, 0, -1))).cut(zc(3.25, b - 46, c0 - 9))
return s
# ---- clash check --------------------------------------------------------------------------------------------------
L("stroke", STROKE, "swept ml", round(math.pi * CI ** 2 * STROKE / 1000, 1))
STATES = {"up_closed": (PIST_TOP_UP, 0.0), "down_closed": (PIST_TOP_DN, 0.0), "down_open": (PIST_TOP_DN, TRAVEL), "up_open": (PIST_TOP_UP, TRAVEL)}
for st, (zt, tr) in STATES.items():
ze = zt - L6; up, lo = piston_parts(zt)
parts = {"cyl": cyl, "cap_bot": cap_bot, "cap_top": cap_top, "disk7": up, "disk8": lo, "tube": tube(zt), "plug": plug(ze),
"grip": grip(ze + tr), "shell": shell(ze + tr)}
ks = list(parts); hits = []
for i in range(len(ks)):
for j in range(i + 1, len(ks)):
a, b2 = ks[i], ks[j]
if {a, b2} in ({"cyl", "cap_bot"}, {"cyl", "cap_top"}, {"tube", "plug"}, {"grip", "shell"}): continue # intended fits
v = parts[a].common(parts[b2]).Volume
if v > 0.01: hits.append(f"{a}x{b2}:{v:.2f}")
# intended fits: the overlap must be only the spigot / stem / thread, checked by volume bounds
L(st, hits, "grip-bottom", round(ze + tr, 1), "cap_bot-bottom", -5)
# fits
L("tube-plug overlap", round(tube(200).common(plug(10)).Volume, 2), "grip-shell overlap", round(grip(0).common(shell(0)).Volume, 2))
L("lug tip r 9.0 vs shell bore r 10.0; open-stop: lugs meet cone", round(shell(TRAVEL).common(plug(0)).Volume, 3), "(>0 means travel too long)")
# how far up the valve can go before the cone touches the stops
for tr in (0.0, 11.0, 11.8, 12.0, 12.2, 12.5):
L(" travel", tr, "cone x stops", round(shell(tr).common(plug(0)).Volume, 3), " grip x stops", round(grip(tr).common(plug(0)).Volume, 3))
if os.environ.get("NOSAVE") != "1":
import MeshPart
up, lo = piston_parts(0)
prints = {"siphon-cap-top": cap_top, "siphon-cap-bottom": cap_bot, "siphon-piston-upper": up, "siphon-piston-lower": lo,
"siphon-plug": plug(0), "siphon-valve-grip": grip(0), "siphon-valve-shell": shell(0)}
for k, v in prints.items():
L(k, "valid", v.isValid(), "solids", len(v.Solids), "vol cm3", round(v.Volume / 1000, 2))
MeshPart.meshFromShape(Shape=v, LinearDeflection=0.03, AngularDeflection=0.15).write(OUT + k + ".stl")
if os.environ.get("HERO") == "1":
import FreeCADGui as Gui
zt = PIST_TOP_UP - 40; ze = zt - L6; up, lo = piston_parts(zt)
def torus(R, r, z): return Part.makeTorus(R, r, V(0, 0, z), V(0, 0, 1))
orings = torus(16.25, 1.25, 6.0).fuse(torus(16.25, 1.25, LC - 6.0)).fuse(torus(15.25, 1.75, zt - DISK_T - SEAT / 2))
orings = orings.fuse(torus(5.6, 0.75, ze + 3.5)).fuse(torus(5.6, 0.75, ze + 14.5))
d = App.newDocument("h")
petg, steel, acr, blk = (0.93, 0.93, 0.90), (0.72, 0.73, 0.76), (0.80, 0.90, 0.95), (0.12, 0.12, 0.12)
items = [("cyl", cyl, acr, 70), ("cap_bot", cap_bot, petg, 0), ("cap_top", cap_top, petg, 0), ("disk7", up, petg, 0), ("disk8", lo, petg, 0),
("tube", tube(zt), steel, 0), ("plug", plug(ze), petg, 0), ("grip", grip(ze), petg, 0), ("shell", shell(ze), petg, 0), ("orings", orings, blk, 0)]
for n, sh, c, tr in items:
o = d.addObject("Part::Feature", n); o.Shape = sh; d.recompute()
vo = Gui.ActiveDocument.getObject(n); vo.ShapeColor = c; vo.Transparency = tr
v = Gui.ActiveDocument.ActiveView
v.setCameraType("Orthographic"); v.setViewDirection((-0.5, -0.8, -0.33)); v.fitAll(); Gui.updateGui()
v.saveImage(OUT + "hero.png", 1000, 1600, "White"); L("hero saved")
LOG.close()
os._exit(0)