In a system where multiple types of energy source exist, running all components at all available times could be a waste by considering multiple different factors, including the device depreciation, normal energy in maintaining the entire system running. This waste is a significant factor when lower wind for wind producer happen, or lower light for light producer happen, or other stuff.
This is a web based energy running simulation simulator with jsLpsolver to find optimal threshold, which will be used to determine the time to turn on the device and time to turn off. It contains methods to analyze history data to predict a threshold to make the entire system running as efficient as it could. After proper data is provided, system will run based on a threshold setting from user or automatically analyzed based on history data so that no energy will be wasted. This app is done solely by me. More details is as below:
Ways of analyzing history data
If Using the first 30 input data to optimize and get the best possible threshold.
is checked, the first 30 data will be used to generate the optimized threshold.
By comparing methods in passage Optimal Energy Production designed by me and the usage case, the following one is chosen:
Define variables
J : type of energy, {wind, water, }
N : value index, 1, 2, .
C = : the normal energy consumption per unit time for each producer (Need to consider as a combination of multiple equipments, like: if we have two wind machine(user is able to define this in control), each machine will consume 10 W. Then =10*2=20)
U = : Total user consumption
W = , the expected energy(total in above table) produced in each value index, either pre-calculated or calculate in model.
S = {0,1}, to indicate I should turn on wind on this statistic data or not
B : The battery charging limitation.
D , indicate the day count each value index, either pre-calculated or calculate in model.
Optimization Model
\begin{equation}\begin{split}&\text{Minimize } & \sum_{i\in N}\sum_{j\in J}D_{ij}S_{ij}\\& \text{Subject to}\ & 0 \le S_{ij} \le 1 \ \forall i\in N j\in J\\& & \sum_{i\in N}\sum_{j\in J}W_{ij}S_{ij}-\sum_{i\in N}\sum_{j\in J}C_{j}S_{ij}-U\ge B\end{split}\end{equation}Use MIP to solve it
Code to solve it
This code including reading data from file using papaparse, papaparse also contains ways to read stream. Such that streaming data would be easily handled in the real situation. And the optimization is solved by using jsLpsolver.
1 | var days = 0; |
Running
Basically, this page is served as a Github page, you could visit at shaokangjiang.github.io/energy/.
This website also has a lightweight localization, which will switch between ZH-CN and EN-US based on the system configuration. This is a pure static page with JavaScript. So anybody is able to host it easily on your own. If you don’t need to see some 3d effects, just download and click on each file would work. 3D effects require some cross-server interaction.
To run it and see the 3d effects, the way I use is to install Node.js at first. Then install the http-server using npm install --global http-server
. Then do the following in any directory:
1 | git clone https://github.com/ShaokangJiang/energy.git |
Then go to browser and go to 127.0.0.1:8080
should work.
Interactive content
3D model
3D model with real time running information is available while running. This is done by using A-Frame with Three.js
AR
By scanning specific pattern, it is able to load model in reality. /ar.html
and /ar1.html
provide two different ways, one is scanning via QR code, the other way is through scanning the 2D version of this 3D model, this is done based on machine learning of the configured pattern.
Wonderful charts
When hovering mouse on each card, it is able to plot the energy production in the past 10 time durations.
Data format:
Simulation data
Header should be the same, User_Usage
is not required but recommend. Each field represent the value sensor received.
1 | Time,Wind_Speed,Light_H,Wave_Hight,Wave_Period,Current_Speed,User_Usage |
Download a sample from here.
Optimization data
Header should be the same, idx
is not required. Each category has a value component recoding the amount of power produced in unit time. Each count means the possibility of happening. Because we need to use a KWH = b KW * s/3600 to calculate energy produced. The count field has to be integer. We could use the possibility * a factor to make it become integer. And the sum of each count should be the same.
1 | idx,wind_value,wind_count,light_value,light_count,wave_value,wave_count,current_value,current_count |
Download a sample from here.
Generate Fake Simulation and optimization data
Fake simulation data
Use java code below to generate fake simulation data(to be used in run page).
1 | static Random r = new Random(); |
Fake optimization data
To make the input source be easy to manage, represent and maintain. We could save them in the same file, if no enough data for a cell, leave it empty would be fine and recommended.
idx is not required but recommended
This generation code might be good enough as this is not the real case
header: idx,wind_value,wind_count,light_value,light_count,wave_value,wave_count,current_value,current_count
Use java code below to generate fake optimization data(to be used in start page):
1 | public static void main(String[] args) throws IOException { |
Usage
Each field means the threshold of each component except wave. In the case of wave, the threshold needs to be pre-calculated using $H^2T$. User usage is in kwh per day or unit time, the unit time refers to the refresh frequency, which will be used to calculate energy produced in the frame of time.
The way to calculate energy produced per unit time: a KWH = b KW*s/3600, a is the result, b is the current power, a is the calculated energy. s is the refresh frequency. Refresh frequency in this form is in ms(milliseconds).
In the manual setting, you are able to choose to provide user usage data in the future, usually this means to have a column of data recording user consumption per unit time, it will be used as a source of consumming power. If that file doesn't have user usage, you could set it at here. In the auto generate mode, you have to provide one to let us find the optimal solution(guess a possible one would be fine).
Calculation Equation
Wave: $P_{total}=0.6*11*H^2T=6.6H^2T$ H - height of wave T - period
Ocean Current: $P=\frac{\rho v^3 S C_p}{2}=\frac{1050 v^3 \pi1.3^2* 0.45}{2}=1254v^3$ P is the energy captured by the unit, ρ is the fluid density, V is the fluid velocity, and S is the swept area of the impeller$C_p$ is the energy utilization coefficient
Light: $P=\frac{798*H_A}{365*24}=0.09*H_A, H_A$ Total solar radiation per unit area
Wind: $P=\frac{\rho v^3 S C_p}{2}=\frac{1.293 v^3 9852* 0.45}{2}=2866v^3$ P is the energy captured by the unit, ρ is the fluid density, V is the fluid velocity, and S is the swept area of the impeller$C_p$ is the energy utilization coefficient
Requirement
Because I used the class technique to build LinkedList to use in generating charts, IE is not supported. And there are some requirements for the majority browser as well, see compatibility data at NPM official site. Other than the LinkedList, most of features should work in IE 11.
JS libraries used
ChangeLog
5/25/2020 Core running function finished & Time field in input simulation file is not required
5/26/2020 Multi-language added
5/27/2020 Optimize font and icon loading
5/29/2020 Optimization to find best history result function added & multi-file reading is not allowed in run page now
5/30/2020 User can now use the first 30 seconds of data to run and optimize threshold.
5/31/2020 More verification, notification added. Framework for displaying VR and AR is ready. Supported via static webpage, qrCode, and also in running page.
For AR in static page, your device needs meet WebXR requirement:
AR is also a standard and you can experiment today on Android ARCore compatible devices and Chrome 79 or newer.
Enable the experimental WebXR AR module in chrome://flags6/6/2020 All parts of 3d model is done.
Sample running
Optimization is done automatically and is not shown in this demo.
Demo could be view at Onedrive video