Coverage for fiqus/post_processors/PostProcessConductorAC.py: 57%

28 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2024-09-01 03:24 +0200

1import os 

2import numpy as np 

3import re 

4import matplotlib.pyplot as plt 

5import matplotlib.pylab as pl 

6from matplotlib.animation import FuncAnimation 

7import pandas as pd 

8from scipy import integrate, interpolate 

9from typing import (List, Literal, Callable) 

10from pydantic import BaseModel 

11 

12from fiqus.utils.Utils import FilesAndFolders as Util 

13from fiqus.data.DataFiQuSConductorAC_Strand import CACStrandSolve, CACStrandPostproc, CACStrandMesh, CACStrandGeometry 

14from fiqus.plotters.PlotPythonConductorAC import PlotPython, SimulationData 

15 

16 

17class PostProcess: 

18 """ 

19 This class loads and stores the data from a simulation and can apply various postprocessing operations on the data.  

20 The simulation data is saved as a SimulationData object. 

21 """ 

22 def __init__(self, fdm, model_data_output_path) -> None: 

23 self.fdm = fdm 

24 self.model_data_output_path = model_data_output_path 

25 self.geometry_name = f"Geometry_{self.fdm.run.geometry}" 

26 self.mesh_name = f"Mesh_{self.fdm.run.mesh}" 

27 self.solution_name = f"Solution_{self.fdm.run.solution}" 

28 

29 self.simulation_data = SimulationData(model_data_output_path, self.geometry_name, self.mesh_name, self.solution_name) 

30 

31 def plot_instantaneous_loss(self): 

32 print("Total loss: ", self.simulation_data.cumulative_power["TotalLoss"].iloc[-1]) 

33 print("Total filament loss: ", self.simulation_data.cumulative_power["FilamentLoss"].iloc[-1]) 

34 print("Total coupling loss: ", self.simulation_data.cumulative_power["CouplingLoss"].iloc[-1]) 

35 print("Total eddy loss: ", self.simulation_data.cumulative_power["EddyLoss"].iloc[-1]) 

36 plot_options = self.fdm.magnet.postproc.plot_instantaneous_power 

37 self.simulation_data.plot_instantaneous_power( 

38 show=plot_options.show, 

39 title=plot_options.title, 

40 save_plot=plot_options.save, 

41 save_folder_path=os.path.join(self.model_data_output_path, self.geometry_name, self.mesh_name, self.solution_name), 

42 save_file_name=plot_options.save_file_name, 

43 overwrite=self.fdm.run.overwrite 

44 ) 

45 

46 

47 

48 

49