mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
87 lines
2.8 KiB
Python
87 lines
2.8 KiB
Python
"""
|
|
|
|
name: heat_exchanger.py
|
|
by: Gumyr
|
|
date: October 8th 2022
|
|
|
|
desc:
|
|
|
|
This example creates a model of a parametric heat exchanger core.
|
|
|
|
license:
|
|
|
|
Copyright 2022 Gumyr
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
"""
|
|
from build123d import *
|
|
|
|
exchanger_diameter = 10 * CM
|
|
exchanger_length = 30 * CM
|
|
plate_thickness = 5 * MM
|
|
# 149 tubes
|
|
tube_diameter = 5 * MM
|
|
tube_spacing = 2 * MM
|
|
tube_wall_thickness = 0.5 * MM
|
|
tube_extension = 3 * MM
|
|
bundle_diameter = exchanger_diameter - 2 * tube_diameter
|
|
fillet_radius = tube_spacing / 3
|
|
assert tube_extension > fillet_radius
|
|
|
|
# Generate list of tube locations
|
|
with Workplanes(Plane.XY):
|
|
tube_locations = [
|
|
l
|
|
for l in HexLocations(
|
|
apothem=(tube_diameter + tube_spacing) / 2,
|
|
x_count=exchanger_diameter // tube_diameter,
|
|
y_count=exchanger_diameter // tube_diameter,
|
|
)
|
|
if l.position.length < bundle_diameter / 2
|
|
]
|
|
tube_count = len(tube_locations)
|
|
|
|
# Build the heat exchanger
|
|
with BuildPart() as heat_exchanger:
|
|
with BuildSketch() as tube_plan:
|
|
with Locations(*tube_locations):
|
|
Circle(radius=tube_diameter / 2)
|
|
Circle(radius=tube_diameter / 2 - tube_wall_thickness, mode=Mode.SUBTRACT)
|
|
Extrude(amount=exchanger_length / 2)
|
|
with BuildSketch(
|
|
Plane(
|
|
origin=(0, 0, exchanger_length / 2 - tube_extension - plate_thickness),
|
|
z_dir=(0, 0, 1),
|
|
)
|
|
) as plate_plan:
|
|
Circle(radius=exchanger_diameter / 2)
|
|
with Locations(*tube_locations):
|
|
Circle(radius=tube_diameter / 2 - tube_wall_thickness, mode=Mode.SUBTRACT)
|
|
Extrude(amount=plate_thickness)
|
|
half_volume_before_fillet = heat_exchanger.part.volume
|
|
# Simulate welded tubes by adding a fillet to the outside radius of the tubes
|
|
Fillet(
|
|
*heat_exchanger.edges()
|
|
.filter_by(GeomType.CIRCLE)
|
|
.sort_by(SortBy.RADIUS)
|
|
.sort_by(Axis.Z, reverse=True)[2 * tube_count : 3 * tube_count],
|
|
radius=fillet_radius,
|
|
)
|
|
half_volume_after_fillet = heat_exchanger.part.volume
|
|
Mirror(about=Plane.XY)
|
|
|
|
fillet_volume = 2 * (half_volume_after_fillet - half_volume_before_fillet)
|
|
assert fillet_volume == 469.88331045553787
|
|
|
|
if "show_object" in locals():
|
|
show_object(heat_exchanger.part.wrapped)
|