fix: Fix syntax errors, wire config-driven simulation in run.py, and correct fault-rate/availability KPI bugs

This commit is contained in:
2026-07-28 14:32:53 +02:00
parent 36a875b115
commit b10c5bdbef
15 changed files with 268 additions and 29 deletions

36
run.py
View File

@@ -1,10 +1,21 @@
import json
from datetime import datetime
from pvsim.simulator import (
PVSimulator,
SimulationConfig,
SunModel,
WeatherModel,
)
from pvsim.faults import (
FaultConfig,
FaultManager,
)
from pvsim.plant import PVPlant
from pvsim.exporter import (
SimulationExporter,
)
@@ -13,12 +24,16 @@ from pvsim.statistics import (
SimulationStatistics,
)
CONFIG_PATH = 'pv_simulator/config/plant.json'
with open(CONFIG_PATH, 'r') as f:
raw_config = json.load(f)
# ============================================================
# SIMULAZIONE
# ============================================================
config = SimulationConfig(
simulation_config = SimulationConfig(
start=datetime(
2026,
@@ -41,10 +56,25 @@ config = SimulationConfig(
generate_random_faults=True,
)
plant = PVPlant.from_json(CONFIG_PATH)
sun_model = SunModel.from_config(raw_config)
weather_model = WeatherModel.from_config(raw_config, sun_model)
fault_config = FaultConfig.from_config(raw_config)
fault_manager = FaultManager(config=fault_config)
simulator = PVSimulator(
plant=plant,
sun=sun_model,
weather=weather_model,
fault_manager=fault_manager,
)
result = simulator.run(
config
simulation_config
)
@@ -98,4 +128,4 @@ exporter.export_all(
json=True,
statistics=True,
)
)