Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash with forwardLogging and real/imag mixup in devCtrl.py #4

Open
bijwaard opened this issue Sep 11, 2023 · 0 comments
Open

crash with forwardLogging and real/imag mixup in devCtrl.py #4

bijwaard opened this issue Sep 11, 2023 · 0 comments

Comments

@bijwaard
Copy link

bijwaard commented Sep 11, 2023

When forwardLogging is enabled (seems to be default), there seems to be a mixup with commodities across phases that can cause a crash. I turned this crash in to a warning by checking if the commodity is planned or realized, e.g.:

@@ -137,14 +137,17 @@ class DevCtrl(OptCtrl):
 		if self.forwardLogging and self.host.logControllers:
 			for c in signal.commodities:
 				for i in range(0,  signal.planHorizon):
-					self.logValue("W-power.plan.real.c."+c,  self.plan[c][int(signal.time + i*signal.timeBase)].real, int(signal.time + i*signal.timeBase))
-					if self.host.extendedLogging:
-						self.logValue("W-power.plan.imag.c." + c, self.plan[c][int(signal.time + i*signal.timeBase)].imag, int(signal.time + i * signal.timeBase))
+					if c in self.plan:
+						self.logValue("W-power.plan.real.c."+c,  self.plan[c][int(signal.time + i*signal.timeBase)].real, int(signal.time + i*signal.timeBase))
+						if self.host.extendedLogging:
+							self.logValue("W-power.plan.imag.c." + c, self.plan[c][int(signal.time + i*signal.timeBase)].imag, int(signal.time + i * signal.timeBase))
+					else:
+						self.logWarning("W-power.plan.%s, unavailable for %s"%(c, self.name))

-					if self.useEventControl:
-						self.logValue("W-power.realized.imag.c." + c,self.realized[c][int(signal.time + i * signal.timeBase)].imag,int(signal.time + i * signal.timeBase))
+					if self.useEventControl and c in self.realized:
+						self.logValue("W-power.realized.real.c." + c,self.realized[c][int(signal.time + i * signal.timeBase)].real,int(signal.time + i * signal.timeBase))
 						if self.host.extendedLogging:
-							self.logValue("W-power.realized.real.c." + c,self.realized[c][int(signal.time + i * signal.timeBase)].real,int(signal.time + i * signal.timeBase))
+							self.logValue("W-power.realized.imag.c." + c,self.realized[c][int(signal.time + i * signal.timeBase)].imag,int(signal.time + i * signal.timeBase))

 		self.lockPlanning.release()
 		return dict(self.realized)

15:35:25 | WARNING: [LOADCTRL_L1] W-power.plan.EL2, unavailable for LOADCTRL_L1
15:35:27 | WARNING: [LOADCTRL_L1] W-power.plan.EL3, unavailable for LOADCTRL_L1
15:35:27 | WARNING: [LOADCTRL_L2] W-power.plan.EL1, unavailable for LOADCTRL_L2
15:35:27 | WARNING: [LOADCTRL_L2] W-power.plan.EL3, unavailable for LOADCTRL_L2
15:35:27 | WARNING: [LOADCTRL_L3] W-power.plan.EL1, unavailable for LOADCTRL_L3
15:35:27 | WARNING: [LOADCTRL_L3] W-power.plan.EL2, unavailable for LOADCTRL_L3
15:35:27 | WARNING: [PVCTRL_3P_L1] W-power.plan.EL2, unavailable for PVCTRL_3P_L1
15:35:27 | WARNING: [PVCTRL_3P_L1] W-power.plan.EL3, unavailable for PVCTRL_3P_L1
15:35:27 | WARNING: [PVCTRL_3P_L2] W-power.plan.EL1, unavailable for PVCTRL_3P_L2
15:35:27 | WARNING: [PVCTRL_3P_L2] W-power.plan.EL3, unavailable for PVCTRL_3P_L2
...

Furthermore, there seems to be a mixup for real and imaginary logging in the end of the code above and lower down in the same file:

@@ -239,9 +242,9 @@ class DevCtrl(OptCtrl):
 					self.realized[c][t] = plan[c][i]
 
 					if self.forwardLogging:
-						self.logValue("W-power.realized.imag.c." + c,self.realized[c][t].real,t)
+						self.logValue("W-power.realized.real.c." + c,self.realized[c][t].real,t)
 						if self.host.extendedLogging:
-							self.logValue("W-power.realized.real.c." + c,self.realized[c][t].imag,t)
+							self.logValue("W-power.realized.imag.c." + c,self.realized[c][t].imag,t)

Kind regards,
Dennis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant