sysdynpy/simulator.py
def _calculate_value(self, element):
        """Calculates the value for a given element based on the calculation rule.

        This is a recursive function to calculate the value of a flow or
        dynamic variable. The values of flows or dynamic variables can always be
        deduced from parameters or stocks. But it can not be assumed that a dynamic
        variable or flow **directly** depends on only parameters or stocks.

        :param element: The element to calculate a value for.
        :type element: Flow or DynamicVariable
        :return: The calculated value
        :rtype: float
        """
        calc_rule = element.calc_rule

        temp_dict = {}
        # store var_name of input elements as keys in temp_dict.
        # dict values are the values of input_elements
        for inp_elem in element.input_elements:
            if "Stock" in str(type(inp_elem)) or "Parameter" in str(type(inp_elem)):
                temp_dict[inp_elem.var_name] = inp_elem.value
            else:
                temp_dict[inp_elem.var_name] = self._calculate_value(inp_elem)
        
        # replace the reference to the classes in the scope of the lambda expression
        # with the values. __globals__ is a dict, so we can update it.
        for key in temp_dict:
            calc_rule.__globals__[key] = temp_dict[key]

        return calc_rule()
Calculates the value for a given element based on the calculation rule.

        This is a recursive function to calculate the value of a flow or
        dynamic variable. The values of flows or dynamic variables can always be
        deduced from parameters or stocks. But it can not be assumed that a dynamic
        variable or flow **directly** depends on only parameters or stocks.

        :param element: The element to calculate a value for.
        :type element: Flow or DynamicVariable
        :return: The calculated value
        :rtype: float
        
Calculates the value for a given element based on the calculation rule.
This is a recursive function to calculate the value of a flow or
dynamic variable. The values of flows or dynamic variables can always be
deduced from parameters or stocks. But it can not be assumed that a dynamic
variable or flow **directly** depends on only parameters or stocks.
Calculates the value for a given element based on the calculation rule . This is a recursive function to calculate the value of a flow or dynamic variable . The values of flows or dynamic variables can always be deduced from parameters or stocks . But it can not be assumed that a dynamic variable or flow ** directly ** depends on only parameters or stocks .
def _calculate_value(self, element):
        calc_rule = element.calc_rule
        temp_dict = {}
        for inp_elem in element.input_elements:
            if "Stock" in str(type(inp_elem)) or "Parameter" in str(type(inp_elem)):
                temp_dict[inp_elem.var_name] = inp_elem.value
            else:
                temp_dict[inp_elem.var_name] = self._calculate_value(inp_elem)
        for key in temp_dict:
            calc_rule.__globals__[key] = temp_dict[key]
        return calc_rule()
def _calculate_value ( self , element ) : calc_rule = element . calc_rule temp_dict = { } for inp_elem in element . input_elements : if "Stock" in str ( type ( inp_elem ) ) or "Parameter" in str ( type ( inp_elem ) ) : temp_dict [ inp_elem . var_name ] = inp_elem . value else : temp_dict [ inp_elem . var_name ] = self . _calculate_value ( inp_elem ) for key in temp_dict : calc_rule . __globals__ [ key ] = temp_dict [ key ] return calc_rule ( )
Calculates the value for a given element based on the calculation rule.
Calculates the value for a given element based on the calculation rule .
"""Calculates the value for a given element based on the calculation rule.

        This is a recursive function to calculate the value of a flow or
        dynamic variable. The values of flows or dynamic variables can always be
        deduced from parameters or stocks. But it can not be assumed that a dynamic
        variable or flow **directly** depends on only parameters or stocks.

        :param element: The element to calculate a value for.
        :type element: Flow or DynamicVariable
        :return: The calculated value
        :rtype: float
        """ # store var_name of input elements as keys in temp_dict. # dict values are the values of input_elements # replace the reference to the classes in the scope of the lambda expression # with the values. __globals__ is a dict, so we can update it.
The calculated value
The calculated value
float
self
element
The element to calculate a value for.
The element to calculate a value for .