From 51e33a956cb09ed81cca1e3d6cb1206654814d78 Mon Sep 17 00:00:00 2001 From: mj-xmr <63722585+mj-xmr@users.noreply.github.com> Date: Sun, 8 May 2022 08:06:42 +0200 Subject: [PATCH 1/2] Python scripts read battery.json --- batteries.json | 2 +- config.json | 2 -- src/generator.py | 12 +++++++----- src/opti-lib/src/BatteryParams.h | 3 ++- src/opti-lib/src/OptiEnProfitSubject.cpp | 6 +++--- src/sunrise_lib.py | 1 + 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/batteries.json b/batteries.json index 22799dd..3448143 100644 --- a/batteries.json +++ b/batteries.json @@ -6,7 +6,7 @@ "max_discharge_amp" : 11, "max_capacity_amph" : 60, "min_load_amph" : 30, - "discharge_per_hour_percent" : 1.1 + "discharge_per_hour_percent" : 0.9 } ] } diff --git a/config.json b/config.json index 4ca8e00..fc38fb8 100644 --- a/config.json +++ b/config.json @@ -14,9 +14,7 @@ }, "generator": { "ELEVATION_KEY": "elevation", - "MIN_POWER": 0, "MAX_POWER": 40, - "MAX_USAGE": 11, "MIN_CAPACITY": 0, "MAX_CAPACITY": 20, "MUL_POWER_2_CAPACITY": 0.1, diff --git a/src/generator.py b/src/generator.py index 65de073..00036a6 100755 --- a/src/generator.py +++ b/src/generator.py @@ -25,16 +25,18 @@ from python_json_config import ConfigBuilder config = sunrise_lib.config +config_batteries = sunrise_lib.config_batteries +battery = config_batteries.batteries[0] ELEVATION_KEY = config.generator.ELEVATION_KEY BUILD_DIR='build/' # TODO: Config -# Not changable: system params -MIN_POWER = config.generator.MIN_POWER +MIN_POWER = 0 +# Not changable: solar system params MAX_POWER = config.generator.MAX_POWER -MAX_USAGE = config.generator.MAX_USAGE -#MIN_CAPACITY = config.generator.MIN_CAPACITY -MAX_CAPACITY = config.generator.MAX_CAPACITY +MAX_USAGE = battery['max_discharge_amp'] +MIN_CAPACITY = battery['min_load_amph'] +MAX_CAPACITY = battery['max_capacity_amph'] MUL_POWER_2_CAPACITY = config.generator.MUL_POWER_2_CAPACITY T_DELTA_HOURS = config.generator.T_DELTA_HOURS DATE_NOW = sunrise_lib.DATE_NOW diff --git a/src/opti-lib/src/BatteryParams.h b/src/opti-lib/src/BatteryParams.h index e5b40fb..d1a31e6 100644 --- a/src/opti-lib/src/BatteryParams.h +++ b/src/opti-lib/src/BatteryParams.h @@ -9,7 +9,8 @@ struct BatteryParams virtual ~BatteryParams(); double MAX_DISCHARGE_AMP = 11; - static constexpr const double MUL_POWER_2_CAPACITY = 0.1; + /// TODO: Get the conversion right: + static constexpr const double MUL_POWER_2_CAPACITY = 0.1; // = 12 / 230.0 * 0.8; // [V / V] * % loss for conversion double MAX_CAPACITY_AMPH = 60; double MIN_LOAD_AMPH = MAX_CAPACITY_AMPH / 2; //# Assuming a lead-acid double DISCHARGE_PER_HOUR_PERCENT = 0.5; diff --git a/src/opti-lib/src/OptiEnProfitSubject.cpp b/src/opti-lib/src/OptiEnProfitSubject.cpp index c5bb05a..1a55890 100644 --- a/src/opti-lib/src/OptiEnProfitSubject.cpp +++ b/src/opti-lib/src/OptiEnProfitSubject.cpp @@ -62,11 +62,11 @@ double BatterySimulation::iter_get_load(double inp, double out, double hours) double discharge = hours * pars.DISCHARGE_PER_HOUR_PERCENT / 100.0 * load; double balance = inp - out - discharge; double change = balance * pars.MUL_POWER_2_CAPACITY; - if (change > pars.MAX_CAPACITY_AMPH) + if (change > pars.MAX_DISCHARGE_AMP) { //if out > pars.MAX_CAPACITY_AMPH: # A valid possibility num_overused += 1; - change = pars.MAX_CAPACITY_AMPH; + change = pars.MAX_DISCHARGE_AMP; } //#print(change) load += change; @@ -165,7 +165,7 @@ double OptiSubjectEnProfit::GetVerbose(const EnjoLib::Matrix & dataMat, bool ver const SimResult & resLocal = Simulate(i, dataMat, bonusMul); resVisual.Add(resLocal); const double load = batteryCopy.iter_get_load(m_dataModel.GetPowerProduction(i), resLocal.sumPowerUsage); - usages.Add(resLocal.sumPowerUsage); + usages.Add(resLocal.sumPowerUsage * batteryCopy.pars.MUL_POWER_2_CAPACITY); //input.Add(val); loads.Add(load); prod.Add(m_dataModel.GetPowerProduction(i)); diff --git a/src/sunrise_lib.py b/src/sunrise_lib.py index ffa6452..3844a7f 100644 --- a/src/sunrise_lib.py +++ b/src/sunrise_lib.py @@ -24,6 +24,7 @@ config_builder = ConfigBuilder() config = config_builder.parse_config('config.json') +config_batteries = config_builder.parse_config('batteries.json') PROJECT_NAME = "SolOptXMR" PROJECT_SUB_NAME = "Solar Optimal mining of XMR" From fcd58937cc5903ed136eecaf8db839fc9409ec1f Mon Sep 17 00:00:00 2001 From: mj-xmr <63722585+mj-xmr@users.noreply.github.com> Date: Sun, 8 May 2022 08:10:25 +0200 Subject: [PATCH 2/2] Min config --- config.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/config.json b/config.json index fc38fb8..513d231 100644 --- a/config.json +++ b/config.json @@ -14,9 +14,6 @@ }, "generator": { "ELEVATION_KEY": "elevation", - "MAX_POWER": 40, - "MIN_CAPACITY": 0, - "MAX_CAPACITY": 20, "MUL_POWER_2_CAPACITY": 0.1, "T_DELTA_HOURS": 1, "PATH_POSITIONS": "/solar_pos",