Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dct/circuit_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def run_optimization_mysql(act_storage_url: str, act_study_name: str, act_number
def start_proceed_study(dab_config: p_dtos.CircuitParetoDabDesign, number_trials: int,
database_type: str = 'sqlite',
sampler=optuna.samplers.NSGAIIISampler(),
delete_study: bool = False
enable_delete_study: bool = False
):
"""Proceed a study which is stored as sqlite database.

Expand All @@ -245,8 +245,8 @@ def start_proceed_study(dab_config: p_dtos.CircuitParetoDabDesign, number_trials
:type database_type: str
:param sampler: optuna.samplers.NSGAIISampler() or optuna.samplers.NSGAIIISampler(). Note about the brackets () !! Default: NSGAIII
:type sampler: optuna.sampler-object
:param delete_study: Indication, if the old study are to delete (True) or optimization shall be continued.
:type delete_study: bool
:param enable_delete_study: Indication, if the old study are to delete (True) or optimization shall be continued.
:type enable_delete_study: bool
"""
filepaths = CircuitOptimization.load_filepaths(dab_config.project_directory)

Expand Down Expand Up @@ -290,7 +290,7 @@ def start_proceed_study(dab_config: p_dtos.CircuitParetoDabDesign, number_trials
storage = f"sqlite:///{circuit_study_sqlite_database}"

# Check the deleteStudyFlag
if delete_study and os.path.exists(circuit_study_sqlite_database):
if enable_delete_study and os.path.exists(circuit_study_sqlite_database):
with os.scandir(circuit_study_working_directory) as entries:
for entry in entries:
if entry.is_dir() and not entry.is_symlink():
Expand Down
6 changes: 5 additions & 1 deletion dct/circuit_optimization_dtos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ class GeneralInformation:

project_directory: str
circuit_study_name: str
filtered_list_id = []
inductor_study_name: str
transformer_study_name: str
heat_sink_study_name: str
# filtered_list_id: List[int]
filtered_list_id: list[int]
circuit_study_path: str
inductor_study_path: str
transformer_study_path: str
Expand Down
157 changes: 88 additions & 69 deletions dct/dctmainctl.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dct/heat_sink_dtos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@dataclasses.dataclass
class HeatSink:
class HeatSinkBoundaryConditions:
"""Fix parameters for the heat sink cooling."""

t_ambient: float
Expand Down
67 changes: 58 additions & 9 deletions dct/heat_sink_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def init_configuration(toml_heat_sink: dct.TomlHeatSink, toml_prog_flow: dct.Flo
print(f"Fan data path {heat_sink_fan_datapath} does not exists!")
# Return with false if path does not exist
return heat_sink_optimization_successful

# Generate the fan-list
for (_, _, file_name_list) in os.walk(heat_sink_fan_datapath):
fan_list = file_name_list

Expand Down Expand Up @@ -137,19 +137,19 @@ def calculate_r_th_tim(copper_coin_bot_area: float, transistor_cooling: Transist
# Simulation handler. Later the simulation handler starts a process per list entry.
@staticmethod
def _simulation(act_hct_config: hct.OptimizationParameters,
target_number_trials: int, delete_study: bool, debug: bool):
target_number_trials: int, enable_delete_study: bool, debug: bool):
"""
Perform the simulation.

:param target_number_trials: Number of trials for the optimization
:type target_number_trials: int
:param delete_study: True to delete the existing study and start a new one
:type delete_study: bool
:param enable_delete_study: True to delete the existing study and start a new one
:type enable_delete_study: bool
:param debug: Debug mode flag
:type debug: bool
"""
# delete existing study
if delete_study and os.path.exists(act_hct_config.heat_sink_optimization_directory):
if enable_delete_study and os.path.exists(act_hct_config.heat_sink_optimization_directory):
with os.scandir(act_hct_config.heat_sink_optimization_directory) as entries:
for entry in entries:
if entry.is_dir() and not entry.is_symlink():
Expand All @@ -171,16 +171,16 @@ def _simulation(act_hct_config: hct.OptimizationParameters,
# Simulation handler. Later the simulation handler starts a process per list entry.
@staticmethod
def optimization_handler(act_ginfo: type[dct.GeneralInformation], target_number_trials: int,
delete_study: bool = False, debug: bool = False):
enable_delete_study: bool = False, debug: bool = False):
"""
Control the multi simulation processes.

:param act_ginfo: General information about the study
:type act_ginfo: dct.GeneralInformation:
:param target_number_trials: Number of trials for the optimization
:type target_number_trials: int
:param delete_study: True to delete the existing study and start a new one
:type delete_study: bool
:param enable_delete_study: True to delete the existing study and start a new one
:type enable_delete_study: bool
:param debug: Debug mode flag
:type debug: bool
"""
Expand All @@ -194,7 +194,56 @@ def optimization_handler(act_ginfo: type[dct.GeneralInformation], target_number_
if target_number_trials > 100:
target_number_trials = 100

HeatSinkOptimization._simulation(act_sim_config, target_number_trials, delete_study, debug)
HeatSinkOptimization._simulation(act_sim_config, target_number_trials, enable_delete_study, debug)
if debug:
# stop after one circuit run
break

class ThermalCalcSupport:
"""Provides functions to calculate the thermal resistance."""

@staticmethod
def calculate_r_th_copper_coin(cooling_area: float, height_pcb: float = 1.55e-3,
height_pcb_heat_sink: float = 3.0e-3) -> tuple[float, float]:
"""
Calculate the thermal resistance of the copper coin.

Assumptions are made with some geometry factors from a real copper coin for TO263 housing.
:param cooling_area: cooling area in m²
:type cooling_area: float
:param height_pcb: PCB thickness, e.g. 1.55 mm
:type height_pcb: float
:param height_pcb_heat_sink: Distance from PCB to heat sink in m
:type height_pcb_heat_sink: float
:return: r_th_copper_coin, effective_copper_coin_cooling_area
:rtype: tuple[float, float]
"""
factor_pcb_area_copper_coin = 1.42
factor_bottom_area_copper_coin = 0.39
thermal_conductivity_copper = 136 # W/(m*K)

effective_pcb_cooling_area = cooling_area / factor_pcb_area_copper_coin
effective_bottom_cooling_area = effective_pcb_cooling_area / factor_bottom_area_copper_coin

r_pcb = 1 / thermal_conductivity_copper * height_pcb / effective_pcb_cooling_area
r_bottom = 1 / thermal_conductivity_copper * height_pcb_heat_sink / effective_bottom_cooling_area

r_copper_coin = r_pcb + r_bottom

return r_copper_coin, effective_bottom_cooling_area

@staticmethod
def calculate_r_th_tim(copper_coin_bot_area: float, transistor_cooling: TransistorCooling) -> float:
"""
Calculate the thermal resistance of the thermal interface material (TIM).

:param copper_coin_bot_area: bottom copper coin area in m²
:type copper_coin_bot_area: float
:param transistor_cooling: Transistor cooling DTO
:type transistor_cooling: TransistorCooling
:return: r_th of TIM material
:rtype: float
"""
r_th_tim = 1 / transistor_cooling.tim_conductivity * transistor_cooling.tim_thickness / copper_coin_bot_area

return r_th_tim
Binary file added dct/htmltemplates/StyleSheets/Dummytrafo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions dct/htmltemplates/StyleSheets/histogramStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
}

h1 {
color: #333;
}

.image-container {
display: flex;
justify-content: center;
margin-top: 80px;
}

img {
border: 2px solid #333;
border-radius: 10px;
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.2);
max-width: 80%;
height: auto;
}
21 changes: 18 additions & 3 deletions dct/inductor_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def init_configuration(toml_inductor: dct.TomlInductor, toml_prog_flow: dct.Flow

# Create the io_config_list for all trials
for circuit_trial_number in act_ginfo.filtered_list_id:
circuit_filepath = os.path.join(act_ginfo.circuit_study_path, "filtered_results", f"{circuit_trial_number}.pkl")
circuit_filepath = os.path.join(act_ginfo.circuit_study_path, act_ginfo.circuit_study_name, "filtered_results", f"{circuit_trial_number}.pkl")
# Check filename
if os.path.isfile(circuit_filepath):
# Read results from circuit optimization
Expand Down Expand Up @@ -133,7 +133,9 @@ def _simulation(circuit_id: int, act_io_config: fmt.InductorOptimizationDTO, act
process_number = 1

# Load configuration
circuit_dto = dct.HandleDabDto.load_from_file(os.path.join(act_ginfo.circuit_study_path, "filtered_results", f"{circuit_id}.pkl"))
circuit_dto = dct.HandleDabDto.load_from_file(os.path.join(act_ginfo.circuit_study_path,
act_ginfo.circuit_study_name,
"filtered_results", f"{circuit_id}.pkl"))
# Check number of trials
if target_number_trials > 0:
fmt.optimization.InductorOptimization.ReluctanceModel.start_proceed_study(act_io_config, target_number_trials=target_number_trials)
Expand Down Expand Up @@ -238,7 +240,8 @@ def _simulation(circuit_id: int, act_io_config: fmt.InductorOptimizationDTO, act
# Simulation handler. Later the simulation handler starts a process per list entry.
@staticmethod
def simulation_handler(act_ginfo: type[dct.GeneralInformation], target_number_trials: int,
factor_min_dc_losses: float = 1.0, factor_dc_max_losses: float = 100, re_simulate: bool = False, debug: bool = False):
factor_min_dc_losses: float = 1.0, factor_dc_max_losses: float = 100, enable_delete_study: bool = False,
re_simulate: bool = False, debug: bool = False):
"""
Control the multi simulation processes.

Expand All @@ -250,6 +253,8 @@ def simulation_handler(act_ginfo: type[dct.GeneralInformation], target_number_tr
:type factor_min_dc_losses : float
:param factor_dc_max_losses: Filter factor for the maximum losses, related to the minimum DC losses
:type factor_dc_max_losses: float
:param enable_delete_study: Flag, which indicates to delete the study
:type enable_delete_study: bool
:param re_simulate : Flag to control, if the point are to re-simulate (ASA: Correct the parameter description)
:type re_simulate : bool
:param debug : Debug mode flag
Expand All @@ -264,8 +269,18 @@ def simulation_handler(act_ginfo: type[dct.GeneralInformation], target_number_tr
if target_number_trials > 100:
target_number_trials = 100

# Check the deleteStudyFlag
if enable_delete_study:
# Create path-filename of sqlite database
inductor_study_sqlite_database = os.path.join(act_sim_config[1].inductor_optimization_directory,
Comment thread
gituser789 marked this conversation as resolved.
Outdated
f"{act_sim_config[1].inductor_study_name}.sqlite3")
# Check if path-filename exists
if os.path.exists(inductor_study_sqlite_database):
os.remove(inductor_study_sqlite_database)

InductorOptimization._simulation(act_sim_config[0], act_sim_config[1], act_ginfo, target_number_trials,
factor_min_dc_losses, factor_dc_max_losses, re_simulate, debug)

if debug:
# stop after one circuit run
break
Loading