From 74ecd072739a7ef0b69b08c2c324c32f9cc02163 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 3 Apr 2024 16:24:57 -0700 Subject: [PATCH] allow states to be json --- afc/ctrlWrapper.py | 4 ++++ dev/Development-ControllerWrapper.ipynb | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/afc/ctrlWrapper.py b/afc/ctrlWrapper.py index 14d9439..a1febfc 100644 --- a/afc/ctrlWrapper.py +++ b/afc/ctrlWrapper.py @@ -269,7 +269,11 @@ def compute(self): data['battery_reg'] = 0 # Update SOCs + if isinstance(self.input['temps-initial'], str): + self.input['temps-initial'] = json.loads(self.input['temps-initial']) self.parameter['zone']['temps_initial'] = self.input['temps-initial'] + if isinstance(self.input['facade-initial'], str): + self.input['facade-initial'] = json.loads(self.input['facade-initial']) self.parameter['facade']['fstate_initial'] = self.input['facade-initial'] # Make sure temp_initial is feasible diff --git a/dev/Development-ControllerWrapper.ipynb b/dev/Development-ControllerWrapper.ipynb index 3f416b0..492b987 100644 --- a/dev/Development-ControllerWrapper.ipynb +++ b/dev/Development-ControllerWrapper.ipynb @@ -66,9 +66,9 @@ "CO2 Emissions [kg]\t\t0.0\n", "\n", "Duration:\n", - " {'duration': {'radiance': 30.761962890625, 'glare': 70.15064311027527, 'varts': 0.13178372383117676, 'optall': 0.5088160037994385, 'outputs': 0.0061244964599609375, 'all': 105.49714946746826}}\n", + " {'duration': {'radiance': 30.463333129882812, 'glare': 69.8858585357666, 'varts': 0.13012290000915527, 'optall': 0.5115549564361572, 'outputs': 0.00562286376953125, 'all': 105.02531147003174}}\n", "Optimization:\n", - " {'opt-stats': {'duration': 0.20841765403747559, 'termination': 'optimal', 'objective': 20.28974844}}\n" + " {'opt-stats': {'duration': 0.20725703239440918, 'termination': 'optimal', 'objective': 20.28974844}}\n" ] }, { @@ -354,7 +354,11 @@ " data['battery_reg'] = 0\n", "\n", " # Update SOCs\n", + " if isinstance(self.input['temps-initial'], str):\n", + " self.input['temps-initial'] = json.loads(self.input['temps-initial'])\n", " self.parameter['zone']['temps_initial'] = self.input['temps-initial']\n", + " if isinstance(self.input['facade-initial'], str):\n", + " self.input['facade-initial'] = json.loads(self.input['facade-initial'])\n", " self.parameter['facade']['fstate_initial'] = self.input['facade-initial']\n", "\n", " # Make sure temp_initial is feasible\n",