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

Revision 1469, 3.9 KB checked in by wojtekp, 10 years ago (diff)
Line 
1package test.simpat.models.recs;
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 = 10;
31        private static double Pfull = 76;
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 = Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100; 
45                return powerConsumption;
46        }
47
48        @Override
49        public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
50
51                Node node = (Node) resource;
52                Processor cpu = node.getProcessors().get(0);
53                double Pserv = 0;
54
55                double R = 0;
56                double Rb = 0;
57                double Rcv = 0;
58                try{
59                        Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue();
60                } catch (Exception e){
61                        //
62                }
63               
64                double k = 0;
65                try{
66                        k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue();
67                } catch (Exception e){
68                        //
69                }
70               
71                double a = 0;
72                try{
73                        a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue();
74                } catch (Exception e){
75                        a = 1;
76                }
77
78
79                double C = 0;
80                try{
81                        C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue();
82                } catch (Exception e){
83                        //
84                }
85               
86                double V = 0;
87               
88                for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
89                        if(device.getType().equals(StandardResourceType.Fan)){
90                                if(Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(node.getName().split("_")[1])){
91                                        Fan fan = (Fan) device;
92                                        V = fan.getAirflowInterface().getRecentAirflow().getValue();
93                                        break;
94                                }
95                        }
96                }
97
98                Rcv =  1/ (k * Math.pow(V, a));
99                R = Rb + Rcv; 
100               
101                double K = 0;
102                double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY;
103                double ro = EnvironmentConditions.AIR_DENSITY;
104
105                K = V * Cair * ro;
106                //System.out.println("-------K: " + K +  "; V:" + V);
107
108                double delta_t = Sim_system.clock() - timestamp;
109
110                double Tin = EnvironmentConditions.ROOM_TEMPERATURE;
111                Pserv = node.getPowerInterface().getRecentPowerUsage().getValue();
112               
113                NodeGroup ng = (NodeGroup) node.getParent();
114                for(Node n: ng.getNodes()){
115                        if(Integer.valueOf(n.getName().split("_")[1]) - Integer.valueOf(node.getName().split("_")[1]) == EnvironmentConditions.NODES_IN_A_ROW){
116                                Tin = n.getThermalInterface().getRecentTemperature().getValue();
117                        }
118                }
119               
120                double targetTemp = Pserv/K + Tin; 
121                objective_temperature = targetTemp;
122
123                new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C));
124
125                // 5) save everything
126                timestamp = Sim_system.clock();
127                old_temperature = new_temperature;
128
129                return new_temperature;
130        }
131}
Note: See TracBrowser for help on using the repository browser.