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

Implement rvars across all sub-components and components #379

Open
rburghol opened this issue Sep 9, 2021 · 0 comments
Open

Implement rvars across all sub-components and components #379

rburghol opened this issue Sep 9, 2021 · 0 comments

Comments

@rburghol
Copy link
Collaborator

rburghol commented Sep 9, 2021

The default implementation had 2 variables to track inputs and outputs from sub-components:

  • vars A list of all variables either read by this object (i.e. arguments in an equation) or written by this object on the parent.
  • wvars: A list of variables written by this object on the parent.

There is a note in the source code in the base modelObject class in orderOperations() (see) that:

//       @todo: rvars on subcomps are explicit independent inputs to subcomps that are not yet handled
//        wvars are explicit outputs from subcomps that are often used by other comps
...

Some objecdts have begun to implement this, such as hydroImpSmall, but most others do not. For example: after the line $this->vars[] = $thisop; in the Equation class we should add $this->rvars[] = $thisop; to make the rvars a valid indicator of required inputs (see Code 1 below). We need to:

Code 1: The parseOperands() function in class Equation (see code here).

   function parseOperands() {
      $ops = array();
      $arOperands = preg_split('/[\)\(\+\-\*\/\\^]/',$this->equation);
      foreach ($arOperands as $thisop) {
         $thisop = ltrim(rtrim($thisop));
         if (!is_numeric($thisop) and (strlen($thisop) > 0)) {
            # not numeric, must be a variable, not a constant
            # check to see if it has been added already
            if (!in_array($thisop, $this->vars)) {
               $this->vars[] = $thisop;
            }
         }
      }
   }
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

1 participant