source: DCWoRMS/branches/coolemall/src/test/simpat/models/article/NodeEnergyEstimationPlugin.java @ 1469

Revision 1469, 4.3 KB checked in by wojtekp, 10 years ago (diff)
Line 
1package test.simpat.models.article;
2
3
4import schedframe.resources.StandardResourceType;
5import schedframe.resources.computing.Node;
6import schedframe.resources.computing.Processor;
7import schedframe.resources.computing.coolemall.NodeGroup;
8import schedframe.resources.computing.profiles.energy.ResourceEvent;
9import schedframe.resources.devices.Device;
10import schedframe.resources.devices.Fan;
11import schedframe.resources.devices.PhysicalResource;
12import schedframe.scheduling.manager.tasks.JobRegistry;
13import simulator.DataCenterWorkloadSimulator;
14import test.simpat.EnvironmentConditions;
15import eduni.simjava.Sim_system;
16import example.energy.BaseEnergyEstimationPlugin;
17
18public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
19
20        private static double Tidle = 26;
21
22        private double timestamp = 0;
23        private double old_temperature = Tidle;
24        private double new_temperature = -1;
25        private double objective_temperature = Tidle;
26        private boolean fan = false;
27       
28        private double next_timer = -1;
29
30        private static double Pidle = 6;
31        private static double Pfull = 16;
32
33
34        public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
35                        PhysicalResource resource) {
36                Node node = (Node) resource;
37                double powerConsumption = 0;
38
39                double Pcpu = 0;       
40                for(Processor cpu: node.getProcessors()){
41                        Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue();
42                }
43               
44                powerConsumption = Pcpu + Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100;
45                //powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
46                return powerConsumption;
47        }
48
49        @Override
50        public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
51
52                Node node = (Node) resource;
53                Processor cpu = node.getProcessors().get(0);
54                double Pserv = 0;
55
56                double R = 0;
57                double Rb = 0;
58                double Rcv = 0;
59                try{
60                        Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue();
61                } catch (Exception e){
62                        //
63                }
64               
65                double k = 0;
66                try{
67                        k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue();
68                } catch (Exception e){
69                        //
70                }
71               
72                double a = 0;
73                try{
74                        a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue();
75                } catch (Exception e){
76                        a = 1;
77                }
78
79
80                double C = 0;
81                try{
82                        C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue();
83                } catch (Exception e){
84                        //
85                }
86               
87                double V = 0;
88                double Pfan = 0;
89                for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
90                        if(device.getType().equals(StandardResourceType.Fan)){
91                                if(Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(node.getName().split("_")[1]) || Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW){
92                                        Fan fan = (Fan) device;
93                                        V = fan.getAirflowInterface().getRecentAirflow().getValue();
94                                        Pfan =  fan.getPowerInterface().getRecentPowerUsage().getValue();
95                                        break;
96                                }
97                        }
98                }
99
100                Rcv =  1/ (k * Math.pow(V, a));
101                R = Rb + Rcv; 
102               
103                double K = 0;
104                double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY;
105                double ro = EnvironmentConditions.AIR_DENSITY;
106
107                K = V * Cair * ro;
108                //System.out.println("-------K: " + K +  "; V:" + V);
109
110                double delta_t = Sim_system.clock() - timestamp;
111
112                double Tin = EnvironmentConditions.ROOM_TEMPERATURE;
113                Pserv = node.getPowerInterface().getRecentPowerUsage().getValue();
114                Pserv = Pserv + Pfan;
115               
116                NodeGroup ng = (NodeGroup) node.getParent();
117                for(Node n: ng.getNodes()){
118                        if(Integer.valueOf(n.getName().split("_")[1]) - Integer.valueOf(node.getName().split("_")[1]) == EnvironmentConditions.NODES_IN_A_ROW){
119                                Tin = n.getThermalInterface().getRecentTemperature().getValue();
120                        }
121                }
122               
123                double targetTemp = Pserv/K + Tin; 
124                objective_temperature = targetTemp;
125
126                new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C));
127
128                // 5) save everything
129                timestamp = Sim_system.clock();
130                old_temperature = new_temperature;
131
132                return new_temperature;
133        }
134}
Note: See TracBrowser for help on using the repository browser.