Closed eranschweitzer closed 2 years ago
I get the following error when I try to run this; can you investigate @eranschweitzer?
--- Iter 13: Iteration Status = ITERATING, Passed Iteration Requestion = ITERATE_IF_NEEDED
Subscriptsion:
EV 1 received current 30.00 from input Battery/EV1_current
current array=[30.001884644947673, 30.001884644947673]
EV 2 received current 29.99 from input Battery/EV2_current
current array=[29.9906733230004, 29.9906733230004]
EV 3 received current 30.00 from input Battery/EV3_current
current array=[29.99621865849638, 29.99621865849638]
EV 4 received current 29.99 from input Battery/EV4_current
current array=[29.994278923744197, 29.994278923744197]
EV 5 received current 104.00 from input Battery/EV5_current
current array=[104.00196655685362, 103.93626727286319]
Error = 0.06569928399042624
Calculation Update:
--voltage_update type: contant current
EV 1 charging voltage (V): 50.74
--voltage_update type: contant current
EV 2 charging voltage (V): 83.20
--voltage_update type: contant current
EV 3 charging voltage (V): 154.69
--voltage_update type: contant current
EV 4 charging voltage (V): 118.95
--voltage_update type: contant current
EV 5 charging voltage (V): 243.48
Publications: (helics mode: INITIALIZATION)
Published Charger/EV1_voltage with value 50.74
Published Charger/EV2_voltage with value 83.20
Published Charger/EV3_voltage with value 154.69
Published Charger/EV4_voltage with value 118.95
Published Charger/EV5_voltage with value 243.48
--- Iter 14: Iteration Status = NEXT_STEP, Passed Iteration Requestion = ITERATE_IF_NEEDED
Traceback (most recent call last):
File "/Users/hard312/source/HELICS/HELICS-Examples/user_guide_examples/advanced/advanced_iteration/Charger_noitermain.py", line 226, in <module>
state_plot(vinit, "noiter_main/advanced_iteration_voltage_init.png",
File "/Users/hard312/source/HELICS/HELICS-Examples/user_guide_examples/advanced/advanced_iteration/iterutils.py", line 108, in state_plot
plt.savefig(savename, format="png")
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/matplotlib/pyplot.py", line 979, in savefig
res = fig.savefig(*args, **kwargs)
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/matplotlib/figure.py", line 3046, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 2319, in print_figure
result = print_method(
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 1648, in wrapper
return func(*args, **kwargs)
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 415, in wrapper
return func(*inner_args, **inner_kwargs)
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 541, in print_png
mpl.image.imsave(
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/matplotlib/image.py", line 1675, in imsave
image.save(fname, **pil_kwargs)
File "/Users/hard312/opt/anaconda3/envs/HELICSv321_py3104/lib/python3.10/site-packages/PIL/Image.py", line 2297, in save
fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'noiter_main/advanced_iteration_voltage_init.png'
Yeah, it's because I saved these figures into a separate folder called 'noiter' so they wouldn't overwrite the other figures but you if course don't just happen to have that folder on your machine 🤦 I'll fix it at the latest by Monday.
@trevorhardy please try now. Problem should be gone.
That fixed it; thanks!
Summary
If merged this pull request will elaborate and improve the iteration example but adding a version where iteration is turned off for comparison.
Proposed changes
The
Battery.py
andCharger.py
scripts have been slightly updated so that a single flagiterative_mode
can be set toTrue
orFalse
to either use iteration or not (only in time loop, initialization iteration is maintained in both cases.)A copy of the federates is then created where
iterative_mode=False
(as well as a few save path differences for the figures).A user is then able to run both examples and observe the impact of enabling iteration.