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

Defaults > Hydraulics > Pattern #333

Open
s-u-m-a-n-t-h opened this issue Feb 13, 2023 · 5 comments
Open

Defaults > Hydraulics > Pattern #333

s-u-m-a-n-t-h opened this issue Feb 13, 2023 · 5 comments
Assignees
Labels

Comments

@s-u-m-a-n-t-h
Copy link

  • For bug reports and code questions: provide a summary, information on your computing environment, and a simple example that replicates the issue. Water network models are available in the examples folder.
  • For feature requests and general questions: provide a summary.

Summary

In epanet, under project defaults>Hydraulics>Pattern , if the value is a string like 'time' or if it is a number that's not '1' , the wntr io does not allow importing the file. I found the following lines in wntr io relevant to this issue :

ln no 235 : class InpFile(object):
"""
EPANET INP file reader and writer class.
This class provides read and write functionality for EPANET INP files.
The EPANET Users Manual provides full documentation for the INP file format.
"""
.
.
.
.

ln no 342 : self._read_patterns()
.
.
.
.
ln no 973: def _read_patterns(self):
_patterns = OrderedDict()
for lnum, line in self.sections['[PATTERNS]']:

        # read the lines for each pattern -- patterns can be multiple lines of arbitrary length

        line = line.split(';')[0]
        current = line.split()
        if current == []:
            continue
        pattern_name = current[0]
        if pattern_name not in _patterns:
            _patterns[pattern_name] = []
            for i in current[1:]:
                _patterns[pattern_name].append(float(i))
        else:
            for i in current[1:]:
                _patterns[pattern_name].append(float(i))
    for pattern_name, pattern in _patterns.items():
        # add the patterns to the water newtork model
        self.wn.add_pattern(pattern_name, pattern)
    **if not self.wn.options.hydraulic.pattern and '1' in _patterns.keys():
        # If there is a pattern called "1", then it is the default pattern if no other is supplied
        self.wn.options.hydraulic.pattern = '1'
    elif self.wn.options.hydraulic.pattern not in _patterns.keys():

        # Sanity check - if the default pattern does not exist and it is not '1' then balk
        # If default is '1' but it does not exist, then it is constant
        # Any other default that does not exist is an error

        if self.wn.options.hydraulic.pattern is not None and self.wn.options.hydraulic.pattern != '1':
            raise KeyError('Default pattern {} is undefined'.format(self.wn.options.hydraulic.pattern))**
        self.wn.options.hydraulic.pattern = None

Environment

Python version, WNTR version, operating system

Example

@s-u-m-a-n-t-h
Copy link
Author

Any response to this please ?

@dbhart
Copy link
Collaborator

dbhart commented Feb 22, 2023

I'm sorry, I totally thought I had responded, and it looks like it never sent.

Can you provide us with just the [PATTERNS] section (or the part of it that is causing issues) that your .inp file is using? We are having trouble replicating the error, and that would probably help us get there quicker. We definitely don't want the whole file or proprietary data, but if you can give some of the patterns section lines, it would be very helpful. Thanks

@dbhart
Copy link
Collaborator

dbhart commented Feb 27, 2023

@s-u-m-a-n-t-h can I see the options section of the .inp file that you got out of EPANET that has the default pattern? Thanks!

@s-u-m-a-n-t-h
Copy link
Author

@dbhart Please find below the [OPTIONS] section of the .inp file when opened with a text editor :

[OPTIONS]
Units LPS
Headloss H-W
Specific Gravity 1
Viscosity 1
Trials 500
Accuracy 0.001
Unbalanced Continue 10
Pattern time
Demand Multiplier 1.0
Emitter Exponent 0.5
Quality Cloro mg/L
Diffusivity 1
Tolerance 0.01

Please note that it says time against Pattern.

@s-u-m-a-n-t-h
Copy link
Author

Hi @dbhart , were you able to look at the options section of my input file ?

@kaklise kaklise added the bug label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants