Skip to content

Commit

Permalink
Python reads battery.json (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
mj-xmr authored May 8, 2022
1 parent f2f1167 commit 71c3cf8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion batteries.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
5 changes: 0 additions & 5 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
},
"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,
"T_DELTA_HOURS": 1,
"PATH_POSITIONS": "/solar_pos",
Expand Down
12 changes: 7 additions & 5 deletions src/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/opti-lib/src/BatteryParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/opti-lib/src/OptiEnProfitSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions src/sunrise_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 71c3cf8

Please sign in to comment.