Skip to content

Commit

Permalink
add minimum area to conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
gituser789 committed Oct 2, 2024
1 parent 14d491c commit f70a724
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions examples/heat_sink_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

config = hct.OptimizationParameters(

heat_sink_study_name="trial11",
heat_sink_study_name="trial1_area_1",
heat_sink_optimization_directory=os.path.abspath("example_results"),

height_c_list=[0.02, 0.08],
Expand All @@ -22,9 +22,10 @@
thickness_fin_t_list=[1e-3, 5e-3],
fan_list=fan_list,
t_ambient=40,
area_min=0.02 * 0.1
)

hct.Optimization.start_proceed_study(config=config, number_trials=100)
hct.Optimization.start_proceed_study(config=config, number_trials=10000)

hct.global_plot_settings_font_latex()

Expand Down
7 changes: 4 additions & 3 deletions hct/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def objective(trial: optuna.Trial, config: OptimizationParameters) -> tuple:
if geometry.fin_distance_s <= 0.1e-3:
return float('nan'), float('nan')

if length_l * width_b < config.area_min:
return float('nan'), float('nan')

try:
volume_flow_v_dot, pressure = calc_volume_flow(fan_name, geometry, plot=False)

Expand Down Expand Up @@ -97,7 +100,7 @@ def start_proceed_study(config: OptimizationParameters, number_trials: int,
config_on_disk_filepath = f"{config.heat_sink_optimization_directory}/{config.heat_sink_study_name}.pkl"
if os.path.exists(config_on_disk_filepath):
config_on_disk = Optimization.load_config(config_on_disk_filepath)
difference = deepdiff.DeepDiff(config, config_on_disk, ignore_order=True, significant_digits=10)
difference = deepdiff.DeepDiff(config_on_disk, config, ignore_order=True, significant_digits=10)
if difference:
print("Configuration file has changed from previous simulation. Do you want to proceed?")
print(f"Difference: {difference}")
Expand Down Expand Up @@ -186,8 +189,6 @@ def df_plot_pareto_front(df: pd.DataFrame, figure_size: tuple):
:param figure_size: figures size as a x/y-tuple in mm, e.g. (160, 80)
:type figure_size: tuple
"""
print(df.head())

names = df["number"].to_numpy()
# plt.figure()
fig, ax = plt.subplots(figsize=[x / 25.4 for x in figure_size] if figure_size is not None else None, dpi=80)
Expand Down
3 changes: 3 additions & 0 deletions hct/thermal_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class OptimizationParameters:
# boundary conditions
t_ambient: float

# constraints
area_min: float


@dataclass
class FanData:
Expand Down

0 comments on commit f70a724

Please sign in to comment.