Skip to content

Commit

Permalink
read fem logs only when number is in wanted numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
gituser789 committed Oct 10, 2024
1 parent eb234e4 commit cef66ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 6 additions & 4 deletions femmt/optimization/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,12 @@ def fem_logs_to_df(reluctance_df: pd.DataFrame, fem_results_folder_path: str) ->

index = int(file.replace("case_", "").replace(".json", ""))

reluctance_df.at[index, 'fem_inductance'] = scanned_log_dict['single_sweeps'][0]['winding1']['flux_over_current'][0]
reluctance_df.at[index, 'fem_p_loss_winding'] = scanned_log_dict['total_losses']['winding1']['total']
reluctance_df.at[index, 'fem_eddy_core'] = scanned_log_dict['total_losses']['eddy_core']
reluctance_df.at[index, 'fem_core'] = scanned_log_dict['total_losses']['core']
# only write FEM simulation log results to df in case of reluctance number simulation is already present there
if index in reluctance_df["number"]:
reluctance_df.at[index, 'fem_inductance'] = scanned_log_dict['single_sweeps'][0]['winding1']['flux_over_current'][0]
reluctance_df.at[index, 'fem_p_loss_winding'] = scanned_log_dict['total_losses']['winding1']['total']
reluctance_df.at[index, 'fem_eddy_core'] = scanned_log_dict['total_losses']['eddy_core']
reluctance_df.at[index, 'fem_core'] = scanned_log_dict['total_losses']['core']

# final loss calculation
reluctance_df["combined_losses"] = reluctance_df["fem_eddy_core"] + reluctance_df["fem_p_loss_winding"] + reluctance_df["user_attrs_p_hyst"]
Expand Down
13 changes: 7 additions & 6 deletions femmt/optimization/sto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,12 +1028,13 @@ def fem_logs_to_df(reluctance_df: pd.DataFrame, fem_results_folder_path: str) ->
scanned_log_dict = json.load(log_file)

index = int(file.replace("case_", "").replace(".json", ""))

reluctance_df.at[index, 'fem_inductance'] = scanned_log_dict['single_sweeps'][0]['winding1']['flux_over_current'][0]
reluctance_df.at[index, 'fem_p_loss_winding'] = (
scanned_log_dict['total_losses']['winding1']['total'] + scanned_log_dict['total_losses']['winding2']['total'])
reluctance_df.at[index, 'fem_eddy_core'] = scanned_log_dict['total_losses']['eddy_core']
reluctance_df.at[index, 'fem_core'] = scanned_log_dict['total_losses']['core']
# only write FEM simulation log results to df in case of reluctance number simulation is already present there
if index in reluctance_df["number"]:
reluctance_df.at[index, 'fem_inductance'] = scanned_log_dict['single_sweeps'][0]['winding1']['flux_over_current'][0]
reluctance_df.at[index, 'fem_p_loss_winding'] = (
scanned_log_dict['total_losses']['winding1']['total'] + scanned_log_dict['total_losses']['winding2']['total'])
reluctance_df.at[index, 'fem_eddy_core'] = scanned_log_dict['total_losses']['eddy_core']
reluctance_df.at[index, 'fem_core'] = scanned_log_dict['total_losses']['core']

# final loss calculation
reluctance_df["combined_losses"] = reluctance_df["fem_eddy_core"] + reluctance_df["fem_p_loss_winding"] + reluctance_df["user_attrs_p_hyst"]
Expand Down

0 comments on commit cef66ee

Please sign in to comment.