Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lems/model/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Parameter(LEMSBase):
Stores a parameter declaration.
"""

def __init__(self, name, dimension, description=""):
def __init__(self, name, dimension, minval, maxval, description=""):
"""
Constructor.

Expand Down Expand Up @@ -56,6 +56,14 @@ def __init__(self, name, dimension, description=""):
""" Description of this parameter.
:type: str """

self.minval = minval
""" Minimum value of this parameter.
:type: str """

self.maxval = maxval
""" Maximum value of this parameter.
:type: str """

def toxml(self):
"""
Exports this object into a LEMS XML object
Expand Down Expand Up @@ -309,7 +317,7 @@ class Exposure(LEMSBase):
Stores a exposure specification.
"""

def __init__(self, name, dimension, description=""):
def __init__(self, name, minval, maxval, dimension, description=""):
"""
Constructor.

Expand All @@ -320,6 +328,14 @@ def __init__(self, name, dimension, description=""):
""" Name of the exposure.
:type: str """

self.minval = minval
""" Minimum value of this parameter.
:type: str """

self.maxval = maxval
""" Maximum value of this parameter.
:type: str """

self.dimension = dimension
""" Physical dimension of the exposure.
:type: str """
Expand Down
10 changes: 9 additions & 1 deletion lems/model/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StateVariable(LEMSBase):
Store the specification of a state variable.
"""

def __init__(self, name, dimension, exposure=None):
def __init__(self, name, minval, maxval, dimension, exposure=None):
"""
Constructor.

Expand All @@ -27,6 +27,14 @@ def __init__(self, name, dimension, exposure=None):
""" Name of the state variable.
:type: str """

self.minval = minval
""" Minimum value of this parameter.
:type: str """

self.maxval = maxval
""" Maximum value of this parameter.
:type: str """

self.dimension = dimension
""" Dimension of the state variable.
:type: str """
Expand Down
36 changes: 33 additions & 3 deletions lems/parser/LEMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,14 +985,24 @@ def parse_exposure(self, node):
except:
self.raise_error("<Exposure> must specify a name")

if "minval" in node.lattrib:
minval = node.lattrib["minval"]
else:
minval = 0.0

if "maxval" in node.lattrib:
maxval = node.lattrib["maxval"]
else:
maxval = 0.0

try:
dimension = node.lattrib["dimension"]
except:
self.raise_error("Exposure '{0}' must specify a dimension", name)

description = node.lattrib.get("description", "")

self.current_component_type.add_exposure(Exposure(name, dimension, description))
self.current_component_type.add_exposure(Exposure(name, minval, maxval, dimension, description))

def parse_fixed(self, node):
"""
Expand Down Expand Up @@ -1286,13 +1296,23 @@ def parse_parameter(self, node):
except:
self.raise_error("<Parameter> must specify a name")

if "minval" in node.lattrib:
minval = node.lattrib["minval"]
else:
minval = 0.0

if "maxval" in node.lattrib:
maxval = node.lattrib["maxval"]
else:
maxval = 0.0

try:
dimension = node.lattrib["dimension"]
except:
self.raise_error("Parameter '{0}' has no dimension", name)

description = node.lattrib.get("description", "")
parameter = Parameter(name, dimension, description)
parameter = Parameter(name, dimension, minval, maxval, description)

self.current_component_type.add_parameter(parameter)

Expand Down Expand Up @@ -1638,6 +1658,16 @@ def parse_state_variable(self, node):
else:
self.raise_error("<StateVariable> must specify a name")

if "minval" in node.lattrib:
minval = node.lattrib["minval"]
else:
minval = 0.0

if "maxval" in node.lattrib:
maxval = node.lattrib["maxval"]
else:
maxval = 0.0

if "dimension" in node.lattrib:
dimension = node.lattrib["dimension"]
else:
Expand All @@ -1648,7 +1678,7 @@ def parse_state_variable(self, node):
else:
exposure = None

self.current_regime.add_state_variable(StateVariable(name, dimension, exposure))
self.current_regime.add_state_variable(StateVariable(name, minval, maxval, dimension, exposure))

def parse_structure(self, node):
"""
Expand Down