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

Use pyswmm for the drainage coupling #93

Open
lrntct opened this issue Jun 13, 2020 · 5 comments
Open

Use pyswmm for the drainage coupling #93

lrntct opened this issue Jun 13, 2020 · 5 comments

Comments

@lrntct
Copy link
Contributor

lrntct commented Jun 13, 2020

This would greatly simplify the codebase, and improve maintainability.
See pyswmm/Stormwater-Management-Model#124

On top of the current proposed changes to swmm, the following are necessary:

  • An API function to force AllowPonding
int DLLEXPORT swmm_setAllowPonding(int ap)
// Need to add checks for sim open /started
{
    AllowPonding = ap;
    return 0;
}

More likely, it could be a whole swmm_setSimulationAnalysisSetting function.

  • An API function to get the current time step calling routing_getRoutingStep
@lrntct
Copy link
Contributor Author

lrntct commented Jul 14, 2020

Since 2785fbb, itzi depends on pyswmm. The results seems OK, but it could be improved with the integration of the coupling functions in swmm.

@honglioslo
Copy link

I get error run the example with swmm, could tell me how to solve the error?

honli@geo135-laptop:~/test_itzi/nc_spm_08_grass7$ itzi run swmm.par
Starting simulation of swmm.par...
Loading libraries from /usr/lib/grass78/lib
WARNING: Error during execution: Traceback (most recent call last):
File "/home/honli/.local/lib/python3.8/site-packages/itzi/itzi.py", line 165, in sim_runner_worker
sim_runner.initialize(conf_file).run().finalize()
File "/home/honli/.local/lib/python3.8/site-packages/itzi/itzi.py", line 101, in initialize
self.sim.initialize()
File "/home/honli/.local/lib/python3.8/site-packages/itzi/simulation.py", line 144, in initialize
self.__set_models(self.igis)
File "/home/honli/.local/lib/python3.8/site-packages/itzi/simulation.py", line 118, in __set_models
self.drainage = DrainageSimulation(self.rast_domain,
File "/home/honli/.local/lib/python3.8/site-packages/itzi/drainage.py", line 39, in init
self.swmm5 = swmm.Swmm5()
File "/home/honli/.local/lib/python3.8/site-packages/itzi/swmm/swmm.py", line 37, in init
self.c_swmm5 = c.CDLL(swmm_so)
File "/usr/lib/python3.8/ctypes/init.py", line 373, in init
self._handle = _dlopen(self._name, mode)
OSError: /home/honli/.local/lib/python3.8/site-packages/itzi/swmm/swmm_c.so: cannot open shared object file: No such file or directory

Exception ignored in: <function DrainageSimulation.del at 0x7fcf78e74e50>
Traceback (most recent call last):
File "/home/honli/.local/lib/python3.8/site-packages/itzi/drainage.py", line 77, in del
self.swmm5.swmm_end()
AttributeError: 'DrainageSimulation' object has no attribute 'swmm5'

^CProcess Process-1:3:
Traceback (most recent call last):
File "/home/honli/.local/bin/itzi", line 8, in
sys.exit(main())
File "/home/honli/.local/lib/python3.8/site-packages/itzi/itzi.py", line 56, in main
args.func(args)
File "/home/honli/.local/lib/python3.8/site-packages/itzi/itzi.py", line 240, in itzi_run
itzi_run_one(need_grass_session, conf_file, profile)
File "/home/honli/.local/lib/python3.8/site-packages/itzi/itzi.py", line 184, in itzi_run_one
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
p.join()
File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.8/multiprocessing/process.py", line 149, in join
File "/usr/lib/grass78/etc/python/grass/temporal/c_libraries_interface.py", line 960, in c_library_server
conn.poll(None)
res = self._popen.wait(timeout)
File "/usr/lib/python3.8/multiprocessing/connection.py", line 257, in poll
return self._poll(timeout)
File "/usr/lib/python3.8/multiprocessing/popen_fork.py", line 47, in wait
File "/usr/lib/python3.8/multiprocessing/connection.py", line 424, in _poll
r = wait([self], timeout)
return self.poll(os.WNOHANG if timeout == 0.0 else 0)
File "/usr/lib/python3.8/multiprocessing/connection.py", line 931, in wait
ready = selector.select(timeout)
File "/usr/lib/python3.8/multiprocessing/popen_fork.py", line 27, in poll
File "/usr/lib/python3.8/selectors.py", line 415, in select
fd_event_list = self._selector.poll(timeout)
pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt
KeyboardInterrupt

@honglioslo
Copy link

I can run pyswmm from python, but get errors when use itzi

@Caesar05
Copy link

Caesar05 commented Apr 6, 2022

I get the same error. @honglioslo do you already have a solution for this?

@lrntct
Copy link
Contributor Author

lrntct commented Apr 7, 2022

@honglioslo The issue you're having is not related to this open issue. The current stable version of itzi does not yet use pyswmm as interface. It might solve the issue you're encountering, though.
For some reason, it seems that swmm_c.pyx has not been compiled in your installation. You can try to solve it by following the compiling instructions in the programmer's manual.

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

3 participants