wetrocks/src/wetrocks/immersion_chassis.py

137 lines
4.4 KiB
Python

#!/usr/bin/env python3
"""
Chassis for immersion cooling
"""
from typing import Optional, Tuple
from pydantic import BaseModel
from build123d import *
from ocp_vscode import *
from wetrocks import tslot_extrusion, immersion_tank
import copy
from wetrocks import config as conf
config = conf.WetRocksConfig()
class ImmersionChassisConfig(BaseModel):
tslot_hi_len: float = config.tslot_hi_len
tslot_wide_len: float = config.tslot_wide_len
tslot_deep_len: float = config.tslot_deep_len
tslot_size: float = config.tslot_size
tslot_color: tuple = config.tslot_color
bottom_offset: float = config.chassis_bottom_offset
def compound_chassis(
tslot_hi_len: float,
tslot_wide_len: float,
tslot_deep_len: float,
tslot_size: float,
tslot_color: tuple,
bottom_offset,
):
print("tslot_hi_len", tslot_hi_len)
print("tslot_wide_len", tslot_wide_len)
print("tslot_deep_len", tslot_deep_len)
def create_tslot(length):
"""Creates a tslot with the given length."""
tslot_config = tslot_extrusion.TslotConfig()
tslot_config.tslot_length = length
return tslot_extrusion.create_tslot(**tslot_config.model_dump())
def create_tslot_compound(tslot_length, color):
"""Creates a compound object with the given T-slot length and color."""
tslot = create_tslot(tslot_length)
compound = Compound.make_compound([(tslot.part)])
compound.label = "Tslot"
compound.color = color
return compound
def create_post(x, y, z):
"""Creates a post at the given x, y, and z coordinates."""
return copy.copy(tslot_post).locate(Location(Vector(x, y, z)))
def create_horizontal(x, y, z, rotation=(0, 90, 0)):
"""Creates a horizontal T-slot at the given x, y, and z coordinates with an optional rotation."""
return copy.copy(tslot_horizontal).locate(Location(Vector(x, y, z), rotation))
def create_short(x, y, z, rotation=(270, 0, 0)):
"""Creates a short T-slot at the given x, y, and z coordinates with an optional rotation."""
return copy.copy(tslot_short).locate(Location(Vector(x, y, z), rotation))
# Create tslot extrusions for each length
tslot_post = create_tslot_compound(tslot_hi_len, tslot_color)
tslot_horizontal = create_tslot_compound(tslot_wide_len, tslot_color)
tslot_short = create_tslot_compound(tslot_deep_len, tslot_color)
# Four corner posts
front_left_post = create_post(0, 0, 0)
front_right_post = create_post(tslot_wide_len + tslot_size, 0, 0)
back_left_post = create_post(0, tslot_deep_len + tslot_size, 0)
back_right_post = create_post(
tslot_wide_len + tslot_size, tslot_deep_len + tslot_size, 0
)
# Front Left/Right Long Horizontal Extrusion
bottom_front_horizontal = create_horizontal(
tslot_size, 0, tslot_size + bottom_offset
)
bottom_back_horizontal = create_horizontal(
tslot_size, tslot_deep_len + tslot_size, tslot_size + bottom_offset
)
top_front_horizontal = create_horizontal(tslot_size, 0, tslot_hi_len)
top_back_horizontal = create_horizontal(
tslot_size, tslot_deep_len + tslot_size, tslot_hi_len
)
# Short front/back Extrusion, bottom left
bottom_left_short = create_short(0, tslot_size, tslot_size + bottom_offset)
# Short front/back Extrusion, bottom right
bottom_right_short = create_short(
tslot_wide_len + tslot_size, tslot_size, tslot_size + bottom_offset
)
# Short front/back Extrusion, top left
top_left_short = create_short(0, tslot_size, tslot_hi_len)
# Short front/back Extrusion, top right
top_right_short = create_short(
tslot_wide_len + tslot_size, tslot_size, tslot_hi_len
)
all_assembly = Compound(
label="Immersion Chassis",
children=[
front_left_post,
front_right_post,
back_left_post,
back_right_post,
bottom_front_horizontal,
bottom_back_horizontal,
top_front_horizontal,
top_back_horizontal,
bottom_left_short,
bottom_right_short,
top_left_short,
top_right_short,
],
)
return all_assembly
def main():
chassis_config = ImmersionChassisConfig()
chassis = compound_chassis(**chassis_config.model_dump())
show_object(
chassis,
name="Chassis",
black_edges=True,
)
if __name__ == "__main__":
main()