fix: Fix syntax errors, wire config-driven simulation in run.py, and correct fault-rate/availability KPI bugs
This commit is contained in:
36
run.py
36
run.py
@@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user