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

added SWMM5 engine selector #78

Merged
merged 7 commits into from
Mar 13, 2017
Merged

Conversation

bemcdonnell
Copy link
Member

@bemcdonnell bemcdonnell commented Mar 12, 2017

Covers Issue #77

So put your DLL in the lib folder and run the following:

>>> import pyswmm
>>> pyswmm.lib.use("YourDllHere") # <-- Not a path 
>>>
>>> from pyswmm import Simulation
...

@bemcdonnell bemcdonnell added this to the v0.3.2 milestone Mar 12, 2017
@bemcdonnell bemcdonnell self-assigned this Mar 12, 2017
@bemcdonnell
Copy link
Member Author

Also Covers #74

@goanpeca
Copy link
Contributor

I think that this is not really a good solution in general :-\

The real need here is that people need to have the correct vs runtime. This is out of the scope for a python package, so this should be fixed by telling people on the readme to install the correct runtime for the specific version.

@bemcdonnell
Copy link
Member Author

bemcdonnell commented Mar 12, 2017

@goanpeca, I'm not sure what you mean by correct vs runtime. Could you elaborate?

This is sort of like matplotlib giving you the option to select a backend. My company has a version of swmm that has expanded capability beyond standard EPASWMM. I want the option to use either the SWMM that gets distributed with pyswmm or my company's version of swmm.

@bemcdonnell
Copy link
Member Author

bemcdonnell commented Mar 12, 2017

Maybe I didn't describe what this is doing well enough.

This let's you choose what swmm dll you want to use... Maybe you interpreted this as adding runtime libs to support the swmm.dll? Nope :-)

If the user has a special version of swmm, they drop their version in the lib/windows folder and then call the

'pyswmm.lib.use("swmm5-extended")'

@bemcdonnell bemcdonnell changed the title added dll selector added SWMM5 engine selector Mar 12, 2017
@bemcdonnell
Copy link
Member Author

@goanpeca this feature has lots of uses too. We can use pyswmm to run regression tests to compare old swmm engine output to new. The ability to choose an engine was an original request of @michaeltryby.

@dickinsonre
Copy link

@bemcdonnell One problem with using older engines of SWMM5 is that in some but not many cases the data on the line that has to be parsed is different. I do have good success with newer SWMM5 models in older versions but the SWMM5 inp file usually has to pass through the older version GUI to iron out inp problems.

@bemcdonnell
Copy link
Member Author

@dickinsonre, you certainly raise a good point. In your experience, how many versions back to SWMM5.0 would you say there has been consistency in the structure? Assuming we can get the correct structure in place for each respective model, unless the inflow equations change fundamentally, we should be able to understand and quantify the changes in engine behavior. At the same time, that might be a "risky" exercise. This discussion might be better suited for the SWMM repo

@dickinsonre
Copy link

I just tried a few of the older versions with a new inp file and you are okay going back to 5.0.020 at least but older version of SWMM5 had problems with the INFIL section and other sections and did run. The pascal uexport.pas code is available for all all versions so a universal exporter may be possible (if desired).

@goanpeca
Copy link
Contributor

@bemcdonnell I still don't understand how

If the user has a special version of swmm, they drop their version in the lib/windows folder and then call the
'pyswmm.lib.use("swmm5-extended")'

If it is special and adds extra methods, well then the whole pyswmm needs to account for these extra stuff. For older versions, its similar but I can understand this use case better.

@bemcdonnell
Copy link
Member Author

bemcdonnell commented Mar 12, 2017

@goanpeca, pyswmm is independent. No features will be added to pyswmm that will not work with the "common" distributed version of swmm with pyswmm. We have compiled the toolkit API into previous versions of swmm and want to take advantage of that. I see lots of value to this feature. This is also for the "power users".

The discussion is not so much on "does this add value" but more so does the implementation fit with the project. Having moved most of the Mechanics to pyswmm.lib.init.py, I have enabled us to be able to plan for future OS/ARCH and Thererin allows you to use your version of swmm.

One other great point. If you want to run your project in an older version of EPASWMM that does not have the toolkit API, the basic functionally will still work. "swmm_open" "swmm_run" have been standard entry points since swmm 5.0.

My implementation here provides a much cleaner way to select which engine you want to use. All the paths are handled automagicaly as long as your version of swmm is sitting next to the binaries that come with pyswmm.

@goanpeca
Copy link
Contributor

Sure go ahead, was just asking to understand better ;-)


# Platform Detection
def _platform():
""" Folder based on platform """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""Folder based on platform."""

class _DllPath(object):
"""
DllPath Object.
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""DllPath Object."""

def dll_loc(self):
"""Get/set DLL Name """
return self._dll_loc
@dll_loc.setter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space here

"""
def __init__(self):
self._dll_loc = LIB_SWMM
@property
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space here

self._dll_loc = LIB_SWMM
@property
def dll_loc(self):
"""Get/set DLL Name """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""Get/set DLL Name."""

return self._dll_loc
@dll_loc.setter
def dll_loc(self, value):
"""Set DLL Name """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""Set DLL Name."""

"""Set DLL Name """
self._dll_loc = value
def __call__(self):
""" """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???


def use(arg):
"""
Set the SWMM5 DLL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the SWMM5 DLL. (the period!)

@bemcdonnell bemcdonnell merged commit fca7b4b into pyswmm:master Mar 13, 2017
@bemcdonnell bemcdonnell deleted the selectdll branch March 13, 2017 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants