-
Notifications
You must be signed in to change notification settings - Fork 3
/
1.php
54 lines (44 loc) · 1.69 KB
/
1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
// ------------------------------------------------------------------------------
// Solar self consumption model
// 1. Model Basics: Reading in solar PV data
// ------------------------------------------------------------------------------
$emoncms_dir = "/var/www/emoncms/";
$model_start = 1499554800;
$model_duration = 3600*24*365;
$model_end = $model_start + $model_duration;
$timestep = 30;
require "ModelHelper.php";
$data = new ModelHelper($emoncms_dir,$model_start,$timestep);
$data->input_feed("model:solar2",0);
$data->output_feed("model:solar");
$solar_feed_capacity = 4000; // Solar feed is from a 3 kW system
$solar_capacity = 4000; // Model a 4kW system
$solar_kw = $solar_capacity * 0.001;
$solar_sum = 0;
$solar_kwh = 0;
$itterations = 0;
// Model loop
$time = $model_start;
while(true)
{
// Read in solar PV dataset
$solar = $solar_capacity * $data->read("model:solar2",$time) / $solar_feed_capacity;
if ($solar>$solar_capacity) $solar = $solar_capacity; // max limit
if ($solar<0) $solar = 0; // min limit
$solar_sum += $solar;
// Cumulative kWh calculation
$solar_kwh += ($solar * $timestep) / 3600000.0;
// Write output to output feed
$data->write("model:solar",$solar);
// Keep track of time and model end
$itterations ++;
$time += $timestep;
if ($time>$model_end) break;
}
// Final results
$solar_mean = $solar_sum / $itterations;
$solar_kwh_per_kw = $solar_kwh / $solar_kw;
print "Solar\tkWp: ".number_format($solar_kw,1)."kW\t".number_format($solar_mean,1)."W\t".round($solar_kwh)." kWh\t".round($solar_kwh_per_kw)." kWh/kWp\n";
// Save output feeds
$data->save_all();