def test_heat_conservation_simple(self): # Dimensions of the cubes cubes_dimensions = Dimensions(x=3, z=3, y=3) # Cube material cuboid_material = SMSilicon() # Cuboid initial temperature system_initial_temperature = 273.15 + 45 # Definition of the CPU shape and materials scene_definition = { # Cube 0: (cuboid_material, Cuboid(location=Location(x=0, z=0, y=0), dimensions=cubes_dimensions)) } # Edge size pf 1 mm cube_edge_size = 0.001 cubed_space = Model(material_cubes=scene_definition, cube_edge_size=cube_edge_size, environment_properties=None, simulation_precision="HIGH") initial_state = cubed_space.create_initial_state( default_temperature=system_initial_temperature, environment_temperature=None) max_temperature_vector = [] min_temperature_vector = [] number_of_iterations = 10000 for i in range(number_of_iterations): # Apply energy over the cubed space initial_state = cubed_space.apply_energy( actual_state=initial_state, amount_of_time=0.001) temperature_over_energy_application = cubed_space.obtain_temperature( actual_state=initial_state) min_temperature_one = min( obtain_min_temperature( temperature_over_energy_application).values()) max_temperature_one = max( obtain_max_temperature( temperature_over_energy_application).values()) min_temperature_vector.append(min_temperature_one) max_temperature_vector.append(max_temperature_one) assert (self.float_equal(min(min_temperature_vector), system_initial_temperature, error=0.1)) assert (self.float_equal(max(max_temperature_vector), system_initial_temperature, error=0.1))
def generate_board_temperature_evolution_2d_video(schedule_result: RawSimulationResult, title: Optional[str] = None) -> FuncAnimation: """ Generate a 2D animation of the evolution in the temperature of the processor :param schedule_result: Result of the simulation :param title: Plot title :return: plot """ min_simulation_value = min(min(obtain_min_temperature(i).values()) for i in schedule_result.temperature_measures.values()) max_simulation_value = max(max(obtain_max_temperature(i).values()) for i in schedule_result.temperature_measures.values()) return generate_video_2d_heat_map( schedule_result.temperature_measures, min_temperature=min_simulation_value, max_temperature=max_simulation_value, axis="Z", location_in_axis=1, delay_between_frames_ms=100)
def test_external_conduction_plot_3d_stacked(self): # Configuration # Size of the simulation step simulation_step = 0.1 # Major cycle in seconds major_cycle = 1.0 # Temperature of the system (Celsius degrees) system_temperature = 45 number_of_cores = 1 # Dimensions of the core core_dimensions = Dimensions(x=10, z=2, y=10) # Material of the core core_material = SMSilicon() # Material of the board board_material = SMCooper() # Environment initial temperature environment_temperature = 273.15 + system_temperature # CPU distribution # XXXXXXX # XX0X3XX # XX1X4XX # XX2X5XX # XXXXXXX # Definition of the CPU shape and materials cpu_definition = { # Cores 0: (core_material, Cuboid(location=Location(x=20, z=2, y=10), dimensions=core_dimensions)), # Board 1: (board_material, Cuboid(location=Location(x=0, z=0, y=0), dimensions=Dimensions(x=70, z=2, y=70))) } # Edge size pf 0.5 mm cube_edge_size = 0.001 # Environment properties environment_properties = FEAirFree() external_heat_generators_dynamic_power = { 0: create_energy_applicator( (core_material, Cuboid(location=Location(x=20, z=0, y=10), dimensions=Dimensions(x=10, z=2, y=10))), watts_to_apply=10, cube_edge_size=cube_edge_size) } # Generate cubed space cubed_space = Model(material_cubes=cpu_definition, cube_edge_size=cube_edge_size, external_temperature_booster_points= external_heat_generators_dynamic_power, internal_temperature_booster_points={}, environment_properties=environment_properties, simulation_precision="HIGH") initial_state = cubed_space.create_initial_state( default_temperature=environment_temperature, environment_temperature=environment_temperature) # Initial temperatures temperature_measures: Dict[float, Dict[int, PhysicalCuboid]] = {} temperature_over_before_zero_seconds = cubed_space.obtain_temperature( actual_state=initial_state) temperature_measures[0.0] = temperature_over_before_zero_seconds actual_applied_externally_energy_points = {0} # Apply energy over the cubed space for i in range(round(major_cycle / simulation_step)): initial_state = cubed_space.apply_energy( actual_state=initial_state, external_energy_application_points= actual_applied_externally_energy_points, internal_energy_application_points=set(), amount_of_time=simulation_step) temperature = cubed_space.obtain_temperature( actual_state=initial_state) temperature_measures[i * simulation_step] = temperature # Display temperatures for i in range(round(major_cycle / simulation_step)): time_to_display = i * simulation_step min_temperature = min( obtain_min_temperature( temperature_measures[time_to_display]).values()) max_temperature = max( obtain_max_temperature( temperature_measures[time_to_display]).values()) plot_3d = plot_3d_heat_map_temperature( temperature_measures[time_to_display], min_temperature=min_temperature, max_temperature=max_temperature) plot_3d.show()
def test_internal_conduction_plot(self): # Dimensions of the cubes cubes_dimensions = Dimensions(x=2, z=2, y=2) # Cube 0 material cube_0_material = SMCooper() # Core initial temperature cube_0_initial_temperature = 273.15 + 65 # Board initial temperature environment_temperature = 273.15 + 25 # Min simulation value min_simulation_value = cube_0_initial_temperature - 10 max_simulation_value = cube_0_initial_temperature + 10 # Definition of the CPU shape and materials scene_definition = { # Cores 0: (cube_0_material, Cuboid(location=Location(x=0, z=0, y=0), dimensions=cubes_dimensions)) } # Edge size pf 1 mm cube_edge_size = 0.001 # Environment properties environment_properties = FEAirForced() cubed_space = Model(material_cubes=scene_definition, cube_edge_size=cube_edge_size, environment_properties=environment_properties, simulation_precision="HIGH") initial_state = cubed_space.create_initial_state( default_temperature=environment_temperature, material_cubes_temperatures={0: cube_0_initial_temperature}, environment_temperature=environment_temperature) # Initial temperatures temperature_over_before_zero_seconds = cubed_space.obtain_temperature( actual_state=initial_state) # Apply energy over the cubed space initial_state = cubed_space.apply_energy(actual_state=initial_state, amount_of_time=0.9) temperature_over_before_half_second = cubed_space.obtain_temperature( actual_state=initial_state) # Apply energy over the cubed space initial_state = cubed_space.apply_energy(actual_state=initial_state, amount_of_time=0.9) temperature_over_before_one_second = cubed_space.obtain_temperature( actual_state=initial_state) # Zero seconds plot_3d_heat_map_temperature(temperature_over_before_zero_seconds, min_temperature=min_simulation_value, max_temperature=max_simulation_value) min_temperature = obtain_min_temperature( temperature_over_before_zero_seconds) max_temperature = obtain_max_temperature( temperature_over_before_zero_seconds) print("Temperature before 0 seconds: min", min_temperature, ", max", max_temperature) # Half second plot_3d_heat_map_temperature(temperature_over_before_half_second, min_temperature=min_simulation_value, max_temperature=max_simulation_value) min_temperature = obtain_min_temperature( temperature_over_before_half_second) max_temperature = obtain_max_temperature( temperature_over_before_half_second) print("Temperature before 0.5 seconds: min", min_temperature, ", max", max_temperature) # One second plot_3d_heat_map_temperature(temperature_over_before_one_second, min_temperature=min_simulation_value, max_temperature=max_simulation_value) min_temperature = obtain_min_temperature( temperature_over_before_one_second) max_temperature = obtain_max_temperature( temperature_over_before_one_second) print("Temperature before 1 second: min", min_temperature, ", max", max_temperature)
def test_processor_heat_generation_plot(self): # Dimensions of the core core_dimensions = Dimensions(x=10, z=2, y=10) # Material of the core core_material = SMSilicon() # Material of the board board_material = SMCooper() # Core initial temperature # core_initial_temperature = 273.15 + 65 core_0_initial_temperature = 273.15 + 25 core_1_initial_temperature = 273.15 + 25 core_2_initial_temperature = 273.15 + 25 core_3_initial_temperature = 273.15 + 25 # Board initial temperature board_initial_temperature = 273.15 + 25 # Environment initial temperature environment_temperature = 273.15 + 25 # Min simulation value max_simulation_value = 273.15 + 80 min_simulation_value = 273.15 + 20 # Definition of the CPU shape and materials cpu_definition = { # Cores 0: (core_material, Cuboid(location=Location(x=10, z=2, y=10), dimensions=core_dimensions)), 1: (core_material, Cuboid(location=Location(x=30, z=2, y=10), dimensions=core_dimensions)), 2: (core_material, Cuboid(location=Location(x=10, z=2, y=30), dimensions=core_dimensions)), 3: (core_material, Cuboid(location=Location(x=30, z=2, y=30), dimensions=core_dimensions)), # Board 4: (board_material, Cuboid(location=Location(x=0, z=0, y=0), dimensions=Dimensions(x=50, z=2, y=50))) } # Edge size pf 1 mm cube_edge_size = 0.001 # Environment properties environment_properties = FEAirFree() # CPU energy consumption configuration # Dynamic power = dynamic_alpha * F^3 + dynamic_beta # Leakage power = current temperature * 2 * leakage_delta + leakage_alpha leakage_alpha: float = 0.001 leakage_delta: float = 0.1 dynamic_alpha: float = 19 * 1000**-3 dynamic_beta: float = 2 cpu_frequency: float = 1000 watts_to_apply = dynamic_alpha * (cpu_frequency**3) + dynamic_beta # External heat generators external_heat_generators = { # Dynamic power 0: create_energy_applicator( (core_material, Cuboid(location=Location(x=10, z=2, y=10), dimensions=core_dimensions)), watts_to_apply=watts_to_apply, cube_edge_size=cube_edge_size), # Leakage power 1: create_energy_applicator( (core_material, Cuboid(location=Location(x=10, z=2, y=10), dimensions=core_dimensions)), watts_to_apply=leakage_alpha, cube_edge_size=cube_edge_size), 2: create_energy_applicator( (core_material, Cuboid(location=Location(x=30, z=2, y=10), dimensions=core_dimensions)), watts_to_apply=leakage_alpha, cube_edge_size=cube_edge_size), 3: create_energy_applicator( (core_material, Cuboid(location=Location(x=10, z=2, y=30), dimensions=core_dimensions)), watts_to_apply=leakage_alpha, cube_edge_size=cube_edge_size), 4: create_energy_applicator( (core_material, Cuboid(location=Location(x=30, z=2, y=30), dimensions=core_dimensions)), watts_to_apply=leakage_alpha, cube_edge_size=cube_edge_size) } # Internal heat generators internal_heat_generators = { 0: TMInternal(cuboid=Cuboid(location=Location(x=10, z=2, y=10), dimensions=core_dimensions), boostRateMultiplier=leakage_delta), 1: TMInternal(cuboid=Cuboid(location=Location(x=30, z=2, y=10), dimensions=core_dimensions), boostRateMultiplier=leakage_delta), 2: TMInternal(cuboid=Cuboid(location=Location(x=10, z=2, y=30), dimensions=core_dimensions), boostRateMultiplier=leakage_delta), 3: TMInternal(cuboid=Cuboid(location=Location(x=30, z=2, y=30), dimensions=core_dimensions), boostRateMultiplier=leakage_delta) } # Generate cubed space cubed_space = Model( material_cubes=cpu_definition, cube_edge_size=cube_edge_size, external_temperature_booster_points=external_heat_generators, internal_temperature_booster_points=internal_heat_generators, environment_properties=environment_properties, simulation_precision="HIGH") initial_state = cubed_space.create_initial_state( default_temperature=environment_temperature, material_cubes_temperatures={ 0: core_0_initial_temperature, 1: core_1_initial_temperature, 2: core_2_initial_temperature, 3: core_3_initial_temperature, 4: board_initial_temperature }, environment_temperature=environment_temperature) temperatures_vector = [] # Initial temperatures temperature_over_before_zero_seconds = cubed_space.obtain_temperature( actual_state=initial_state) temperatures_vector.append(temperature_over_before_zero_seconds) # Apply energy over the cubed space number_of_iterations = 10 for i in range(number_of_iterations): initial_state = cubed_space.apply_energy( actual_state=initial_state, external_energy_application_points={0}, # {0, 1, 2, 3, 4}, # internal_energy_application_points={0, 1, 2, 3}, amount_of_time=0.5) temperature = cubed_space.obtain_temperature( actual_state=initial_state) temperatures_vector.append(temperature) for i, temperature in enumerate(temperatures_vector): # Zero seconds plot_3d_heat_map_temperature( temperature, min_temperature=min_simulation_value, max_temperature=max_simulation_value).show() plot_2d_heat_map(temperature, min_temperature=min_simulation_value, max_temperature=max_simulation_value, axis="Z", location_in_axis=1).show() min_temperature = obtain_min_temperature(temperature) max_temperature = obtain_max_temperature(temperature) print("Temperature before", i * 0.5, "seconds: min", min_temperature, ", max", max_temperature)
def test_internal_conduction_with_convection(self): # Dimensions of the cubes cubes_dimensions = Dimensions(x=3, z=3, y=3) # Cube 0 material cuboid_material = SMSilicon() # Core initial temperature cuboid_initial_temperature = 273.15 + 65 # Board initial temperature environment_temperature = 273.15 + 25 # Definition of the CPU shape and materials scene_definition = { # Cores 0: (cuboid_material, Cuboid(location=Location(x=0, z=0, y=0), dimensions=cubes_dimensions)) } # Edge size pf 1 mm cube_edge_size = 0.001 # Environment properties environment_properties = FEAirForced() cubed_space = Model(material_cubes=scene_definition, cube_edge_size=cube_edge_size, environment_properties=environment_properties, simulation_precision="HIGH") initial_state = cubed_space.create_initial_state( default_temperature=environment_temperature, material_cubes_temperatures={0: cuboid_initial_temperature}, environment_temperature=environment_temperature) # Apply energy over the cubed space initial_state = cubed_space.apply_energy(actual_state=initial_state, amount_of_time=0.5) temperature_over_before_half_second = cubed_space.obtain_temperature( actual_state=initial_state) # Apply energy over the cubed space initial_state = cubed_space.apply_energy(actual_state=initial_state, amount_of_time=0.5) temperature_over_before_one_second = cubed_space.obtain_temperature( actual_state=initial_state) # Half second min_temperature_half = obtain_min_temperature( temperature_over_before_half_second) max_temperature_half = obtain_max_temperature( temperature_over_before_half_second) min_temperature_half = min(min_temperature_half.values()) max_temperature_half = max(max_temperature_half.values()) # One second min_temperature_one = obtain_min_temperature( temperature_over_before_one_second) max_temperature_one = obtain_max_temperature( temperature_over_before_one_second) min_temperature_one = min(min_temperature_one.values()) max_temperature_one = max(max_temperature_one.values()) assert (environment_temperature <= min_temperature_half <= cuboid_initial_temperature and max_temperature_half <= cuboid_initial_temperature) assert (environment_temperature <= min_temperature_one <= cuboid_initial_temperature and max_temperature_one <= cuboid_initial_temperature) assert (min_temperature_one <= min_temperature_half and max_temperature_one <= max_temperature_half)
def test_processor_heat_conservation(self): # Dimensions of the core core_dimensions = Dimensions(x=10, z=2, y=10) # Material of the core core_material = SMSilicon() # Material of the board board_material = SMCooper() # System initial temperature system_initial_temperature = 273.15 + 25 # Core initial temperature core_initial_temperature = system_initial_temperature # Board initial temperature board_initial_temperature = system_initial_temperature # Environment initial temperature environment_temperature = system_initial_temperature # Definition of the CPU shape and materials cpu_definition = { # Cores 0: (core_material, Cuboid(location=Location(x=10, z=2, y=10), dimensions=core_dimensions)), 1: (core_material, Cuboid(location=Location(x=30, z=2, y=10), dimensions=core_dimensions)), 2: (core_material, Cuboid(location=Location(x=10, z=2, y=30), dimensions=core_dimensions)), 3: (core_material, Cuboid(location=Location(x=30, z=2, y=30), dimensions=core_dimensions)), # Board 4: (board_material, Cuboid(location=Location(x=0, z=0, y=0), dimensions=Dimensions(x=50, z=2, y=50))) } # Edge size pf 1 mm cube_edge_size = 0.001 # Environment properties environment_properties = FEAirFree() # Generate cubed space cubed_space = Model(material_cubes=cpu_definition, cube_edge_size=cube_edge_size, external_temperature_booster_points={}, internal_temperature_booster_points={}, environment_properties=environment_properties, simulation_precision="HIGH") initial_state = cubed_space.create_initial_state( default_temperature=environment_temperature, material_cubes_temperatures={ 0: core_initial_temperature, 1: core_initial_temperature, 2: core_initial_temperature, 3: core_initial_temperature, 4: board_initial_temperature }, environment_temperature=environment_temperature) min_max_temperatures_vector: List[Tuple[float, float, float]] = [ (0.0, core_initial_temperature, core_initial_temperature) ] # Initial temperatures temperature_over_before_zero_seconds = cubed_space.obtain_temperature( actual_state=initial_state) min_temperature = obtain_min_temperature( temperature_over_before_zero_seconds) max_temperature = obtain_max_temperature( temperature_over_before_zero_seconds) min_max_temperatures_vector.append((0.0, min(min_temperature.values()), max(max_temperature.values()))) # Apply energy over the cubed space number_of_iterations = 100 for i in range(number_of_iterations): initial_state = cubed_space.apply_energy( actual_state=initial_state, amount_of_time=0.001) temperature = cubed_space.obtain_temperature( actual_state=initial_state) min_temperature = obtain_min_temperature(temperature) max_temperature = obtain_max_temperature(temperature) min_max_temperatures_vector.append( (0.0, min(min_temperature.values()), max(max_temperature.values()))) assert all(i > system_initial_temperature - 0.1 for _, i, _ in min_max_temperatures_vector) assert all(i < system_initial_temperature + 0.1 for _, _, i in min_max_temperatures_vector)