asselapathirana / epanettools

EPANET calling API for python.
Other
16 stars 13 forks source link

Problem with saving files #28

Open Am-Now opened 6 years ago

Am-Now commented 6 years ago

Hello, While trying to do multiple simulations, i found out that if the number of simulations exceed 169 python raises the following error message :

File "C:############.py", line 118, in MyFunction es.run() File "C:\Python34\lib\site-packages\epanettools\epanettools.py", line 429, in run Error(self.pd.ENsavehydfile(self.hydraulicfile)) File "C:\Python34\lib\site-packages\epanettools\epanettools.py", line 22, in Error e, pdd_wrapper_class.ENgeterror(e, 500)[1]) AttributeError: type object 'pdd_wrapper_class' has no attribute 'ENgeterror'

I tried to catch the source of the problem in the epanettools library but in vain, it seems the function EN_Close() and EN_HClose aren't working properly.

Here are the things i tried : Changing the Temp files directory to my RAMDISK -> Didn't change a thing. Changing the os.remove() to shutil.rmtree(). in the close() reset() functions in epanettools.py file -> Nthing. ***Turning SaveFile to False -> Now it gets stuck at 250 Simulations and raises another error, if i remember it's about the SavHydFile function.

If you don't have time to fix the issue, is it possible to give a hint on the origin of the problem ?

Btw, I tried other Epanet Libraries for python, did a timing test on the simulation function on each of them found out this library is 10 times faster than the others. So basically there is no other other choice than to fix it !

Thank you.

AMahajna commented 5 years ago

Went through the same experience...

asselapathirana commented 5 years ago

Hi, Yes, this is an issue related to En_Close() not working. I don't think it is easy for me to fix this at this point. This is an artifact of connecting the C code to python. However, there is a workaround that I have used successfully.

  1. Create a python script to run a single run.
  2. Call that script for your loop (multiple runs) that will call this script for calculations. (using a shell call or a process).

Hope this helps Assela Pathirana, IHE Delft Institute for Water Education T: +31(0)15 215 1854 Westvest 7, 2611 AX Delft, The Netherlands

On Mon, 10 Jun 2019 at 00:24, AMahajna notifications@github.com wrote:

Went through the same experience...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/asselapathirana/epanettools/issues/28?email_source=notifications&email_token=AACPWVZB24IOOLVL3WM2W4DPZV7JXA5CNFSM4FMODM62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXITN5Y#issuecomment-500250359, or mute the thread https://github.com/notifications/unsubscribe-auth/AACPWV3GQIZTNS3WCCVJZNLPZV7JXANCNFSM4FMODM6Q .

matthewjameseng commented 4 years ago

Hi, Yes, this is an issue related to En_Close() not working. I don't think it is easy for me to fix this at this point. This is an artifact of connecting the C code to python. However, there is a workaround that I have used successfully. 1. Create a python script to run a single run. 2. Call that script for your loop (multiple runs) that will call this script for calculations. (using a shell call or a process). Hope this helps Assela Pathirana, IHE Delft Institute for Water Education T: +31(0)15 215 1854 Westvest 7, 2611 AX Delft, The Netherlands On Mon, 10 Jun 2019 at 00:24, AMahajna @.***> wrote: Went through the same experience... — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#28?email_source=notifications&email_token=AACPWVZB24IOOLVL3WM2W4DPZV7JXA5CNFSM4FMODM62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXITN5Y#issuecomment-500250359>, or mute the thread https://github.com/notifications/unsubscribe-auth/AACPWV3GQIZTNS3WCCVJZNLPZV7JXANCNFSM4FMODM6Q .

Hi, I ran into the same issue of 169 simulations (shown in this picture: image ). in my attempts to use your suggested workaround I have not been able to surpass 101 simulations (shown in this picture: image ). I'm hoping maybe you can provide some more insight on this issue. I have also included all of my code in the images below. thanks for any help or advice you may be able to give me.

cheers!

Matt

The image below is my simulation code image The image below is my looping code image