subsea-compute-open-artifacts / scripts /render_nitrogen_flow_diagram.py
monish133's picture
Upload open subsea compute engineering artifacts
aa6138d verified
Raw
History Blame Contribute Delete
6.79 kB
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / "assets" / "nitrogen_dry_atmosphere_flow_system.png"
W, H = 1800, 1150
BG = (5, 18, 31)
PANEL = (8, 39, 57)
POD = (14, 52, 70)
CYAN = (56, 189, 248)
TEAL = (45, 212, 191)
WHITE = (245, 250, 255)
MUTED = (148, 163, 184)
GREEN = (74, 222, 128)
ORANGE = (251, 146, 60)
RED = (248, 113, 113)
def font(size, bold=False):
paths = [
"C:/Windows/Fonts/arialbd.ttf" if bold else "C:/Windows/Fonts/arial.ttf",
"C:/Windows/Fonts/calibrib.ttf" if bold else "C:/Windows/Fonts/calibri.ttf",
]
for p in paths:
if Path(p).exists():
return ImageFont.truetype(p, size=size)
return ImageFont.load_default()
F_TITLE = font(62, True)
F_H = font(34, True)
F_B = font(26, False)
F_BB = font(26, True)
F_S = font(20, False)
F_SB = font(20, True)
def rounded(d, box, fill, outline, width=3, radius=24):
d.rounded_rectangle(box, radius=radius, fill=fill, outline=outline, width=width)
def label(d, xy, title, body=None, color=CYAN, width=330):
x, y = xy
d.text((x, y), title, font=F_BB, fill=color)
if body:
lines = wrap(d, body, F_S, width)
yy = y + 34
for line in lines:
d.text((x, yy), line, font=F_S, fill=MUTED)
yy += 25
def wrap(d, text, f, max_width):
words = text.split()
lines, cur = [], ""
for word in words:
test = f"{cur} {word}".strip()
if d.textlength(test, font=f) > max_width and cur:
lines.append(cur)
cur = word
else:
cur = test
if cur:
lines.append(cur)
return lines
def arrow(d, start, end, color, width=6):
d.line([start, end], fill=color, width=width)
x1, y1 = start
x2, y2 = end
if abs(x2 - x1) >= abs(y2 - y1):
direction = 1 if x2 > x1 else -1
pts = [(x2, y2), (x2 - 22 * direction, y2 - 13), (x2 - 22 * direction, y2 + 13)]
else:
direction = 1 if y2 > y1 else -1
pts = [(x2, y2), (x2 - 13, y2 - 22 * direction), (x2 + 13, y2 - 22 * direction)]
d.polygon(pts, fill=color)
def main():
im = Image.new("RGB", (W, H), BG)
d = ImageDraw.Draw(im)
d.text((80, 62), "Nitrogen Dry-Atmosphere System", font=F_TITLE, fill=WHITE)
d.text((84, 137), "Use nitrogen for moisture control and electronics protection. Use liquid coolant for GPU heat removal.", font=F_B, fill=MUTED)
# Pod body
pod_box = (370, 265, 1530, 860)
rounded(d, pod_box, POD, CYAN, width=5, radius=90)
d.text((705, 292), "SEALED SS316L POD", font=F_H, fill=WHITE)
d.text((690, 335), "dry nitrogen internal atmosphere", font=F_B, fill=TEAL)
# External nitrogen kit
rounded(d, (80, 330, 285, 750), PANEL, TEAL, width=3, radius=28)
d.ellipse((125, 370, 240, 565), fill=(12, 67, 83), outline=CYAN, width=4)
d.rectangle((154, 350, 211, 390), fill=(12, 67, 83), outline=CYAN, width=4)
d.text((105, 610), "External N2", font=F_BB, fill=CYAN)
d.text((105, 646), "bottle / service kit", font=F_S, fill=MUTED)
d.text((105, 688), "used for purge,\nbackfill, service", font=F_S, fill=MUTED)
# Regulator and valve
rounded(d, (315, 435, 455, 545), PANEL, CYAN, width=3, radius=20)
d.text((333, 463), "Regulator", font=F_SB, fill=WHITE)
d.text((345, 493), "+ gauge", font=F_S, fill=MUTED)
rounded(d, (500, 435, 670, 545), PANEL, CYAN, width=3, radius=20)
d.text((525, 463), "Purge /", font=F_SB, fill=WHITE)
d.text((525, 493), "backfill valve", font=F_S, fill=MUTED)
arrow(d, (285, 500), (315, 500), TEAL)
arrow(d, (455, 500), (500, 500), TEAL)
arrow(d, (670, 500), (760, 500), TEAL)
# Internal nitrogen loop components
rounded(d, (760, 420, 930, 575), PANEL, TEAL, width=3, radius=24)
d.text((800, 455), "N2 inlet", font=F_BB, fill=TEAL)
d.text((795, 492), "controlled\nbackfill", font=F_S, fill=MUTED)
rounded(d, (1010, 405, 1195, 590), PANEL, TEAL, width=3, radius=24)
d.ellipse((1050, 435, 1155, 540), outline=TEAL, width=5)
d.line((1102, 488, 1145, 448), fill=TEAL, width=5)
d.line((1102, 488, 1060, 448), fill=TEAL, width=5)
d.line((1102, 488, 1102, 540), fill=TEAL, width=5)
d.text((1048, 550), "Circulation fan", font=F_SB, fill=WHITE)
rounded(d, (1280, 420, 1455, 575), PANEL, TEAL, width=3, radius=24)
d.text((1312, 455), "Desiccant", font=F_BB, fill=TEAL)
d.text((1320, 492), "moisture trap", font=F_S, fill=MUTED)
arrow(d, (930, 500), (1010, 500), TEAL)
arrow(d, (1195, 500), (1280, 500), TEAL)
arrow(d, (1367, 575), (1367, 690), TEAL)
arrow(d, (1367, 690), (1010, 690), TEAL)
arrow(d, (1010, 690), (845, 575), TEAL)
d.text((960, 622), "internal N2 recirculation", font=F_S, fill=TEAL)
# Electronics and liquid cooling
rounded(d, (675, 650, 910, 800), (10, 48, 65), CYAN, width=3, radius=18)
d.text((720, 690), "GPU / server", font=F_BB, fill=WHITE)
d.text((705, 727), "electronics volume", font=F_S, fill=MUTED)
rounded(d, (960, 650, 1195, 800), (10, 48, 65), CYAN, width=3, radius=18)
d.text((1000, 690), "Cold plates", font=F_BB, fill=WHITE)
d.text((1000, 727), "liquid loop", font=F_S, fill=MUTED)
arrow(d, (910, 725), (960, 725), CYAN)
rounded(d, (1245, 650, 1475, 800), (10, 48, 65), CYAN, width=3, radius=18)
d.text((1278, 690), "Wet HX / hull", font=F_BB, fill=WHITE)
d.text((1278, 727), "rejects heat to water", font=F_S, fill=MUTED)
arrow(d, (1195, 755), (1245, 755), CYAN)
arrow(d, (1475, 755), (1605, 755), CYAN)
d.text((1588, 700), "surrounding\nwater", font=F_SB, fill=CYAN)
# Relief and monitoring
rounded(d, (690, 875, 1010, 1010), PANEL, ORANGE, width=3, radius=20)
d.text((720, 907), "Pressure + relief", font=F_BB, fill=ORANGE)
d.text((720, 944), "sensor, relief valve,\nservice port", font=F_S, fill=MUTED)
arrow(d, (850, 875), (850, 800), ORANGE)
rounded(d, (1060, 875, 1455, 1010), PANEL, GREEN, width=3, radius=20)
d.text((1090, 907), "Telemetry", font=F_BB, fill=GREEN)
d.text((1090, 944), "humidity, O2 if used, leak,\ntemp, flow, pressure", font=F_S, fill=MUTED)
arrow(d, (1250, 875), (1130, 590), GREEN)
# Warning
rounded(d, (80, 870, 610, 1010), (47, 24, 24), RED, width=3, radius=20)
d.text((110, 905), "Do not use nitrogen as primary cooling", font=F_BB, fill=RED)
d.text((110, 945), "Gas circulation equalizes humidity/temp pockets.\nGPU heat still needs cold plates + liquid loop.", font=F_S, fill=(251, 191, 191))
d.text((80, 1075), "SUBSEA COMPUTE | V0 architecture note", font=F_S, fill=(116, 167, 185))
im.save(OUT, quality=95)
print(OUT)
if __name__ == "__main__":
main()