Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <vector>
- #include <math.h>
- int main()
- {
- std::cout << "define the day-night-cycle time, the max poweroutput of the solar panels, the reduction of solar output and the capacity of the accumulators.\n(standard t=6.94 min SP=60 kW rSP=0 % C=5 MJ)\n";
- float daytime{ 0 };
- std::cout << "day-night-cycle time [min]: ";
- std::cin >> daytime;
- float power{ 0 };
- std::cout << "max power one solar panel can output [kW]: ";
- std::cin >> power;
- float dP{ 0 };
- std::cout << "percentage of reduced solar output [%] :";
- std::cin >> dP;
- float C{ 0 };
- std::cout << "capacity per accumulator [MJ]: ";
- std::cin >> C;
- power = power * (1 - dP / 100) * 1000;
- C = C * pow(10, 6);
- daytime = daytime * 60;
- std::vector<float> t;
- t.push_back(0.0);
- t.push_back(0.100719424460432);
- t.push_back(0.273381294964029);
- t.push_back(0.812949640287770);
- t.push_back(1.0);
- for (int i = 0; i < t.size(); i++) {
- t[i] = t[i] * daytime;
- }
- std::vector<float> P;
- P.push_back(0.0);
- P.push_back(0.0);
- P.push_back(power);
- P.push_back(power);
- P.push_back(0.0);
- float w{ 0 };
- for (int i = 1; i < t.size(); i++) {
- w += 0.5 * (P[i - 1] + P[i]) * (t[i] - t[i-1]);
- }
- float Pm = w / daytime;
- float p1;
- float p2;
- float t1;
- float t2;
- float tch;
- std::vector<float>::iterator it;
- std::vector<float>::iterator itp;
- it = t.begin();
- itp = P.begin();
- for (int i = 0; i < t.size()-1; i++) {
- p1 = P[i];
- p2 = P[i + 1];
- if (p1 < Pm && p2 > Pm) {
- t1 = t[i];
- t2 = t[i + 1];
- tch = t1 + (t2 - t1) / (p2 - p1)*(Pm - p1);
- t.emplace(it + i+1, tch);
- P.emplace(itp + i+1, Pm);
- }
- }
- for (int i = 0; i < t.size() - 1; i++) {
- p1 = P[i];
- p2 = P[i + 1];
- if (p1 > Pm && p2 < Pm) {
- t1 = t[i];
- t2 = t[i + 1];
- tch = t1 + (t2 - t1) / (p2 - p1)*(Pm - p1);
- t.emplace(it + i+1, tch);
- P.emplace(itp + i+1, Pm);
- }
- }
- std::vector<float> Pa;
- for (int i = 0; i < P.size(); i++) {
- Pa.push_back(P[i] - Pm);
- }
- float Ct{ 0 };
- float max{ 0 };
- float min{ 0 };
- for (int i = 1; i < t.size(); i++) {
- Ct += 0.5 * (Pa[i - 1] + Pa[i]) * (t[i] - t[i - 1]);
- if (Ct > max)max = Ct;
- if (Ct < min)min = Ct;
- }
- float Cg = max - min;
- float r = Cg / C;
- std::cout << "You need " << r << " accumulators per solar panel" << std::endl;
- std::cout << "The average power produced per solar panel is " << Pm / 1000 << " kW" << std::endl;
- std::system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement