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

Basic Event Scheduler Model #37

Open
wants to merge 7 commits into
base: devel
Choose a base branch
from
Open

Conversation

mandd
Copy link
Collaborator

@mandd mandd commented Jul 15, 2021


Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

Closes #36

What are the significant changes in functionality due to this change request?

For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual.
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Regression tests have to complete successfully.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test.
  • 6. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.

Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

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

I have couple of comments for your consideration.

__init__.py Outdated
@@ -9,6 +9,7 @@
from SR2ML.src import MaintenanceModel
from SR2ML.src import MCSSolver
from SR2ML.src import MarginModel
from SR2ML.src import basicEventScheduler
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would recommend to use upper case for each leading character when define a class. That is: change basicEventScheduler to BasicEventScheduler

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed

\item \xmlNode{BE}, \xmlDesc{string, required parameter}, the name ID of all basic events
\begin{itemize}
\item \xmlAttr{tin}, \xmlDesc{required string attribute}, name ID of the variable describing the initial time of the BE
\item \xmlAttr{tin}, \xmlDesc{required string attribute}, name ID of the variable describing the final time of the BE
Copy link
Collaborator

Choose a reason for hiding this comment

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

change 'tin' to 'tfin'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed, good catch

# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Copy link
Collaborator

Choose a reason for hiding this comment

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

please update the copyright info, (The above info is used by raven). Something like:

# Copyright 2020, Battelle Energy Alliance, LLC
# ALL RIGHTS RESERVED

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,119 @@
<Simulation verbosity="debug">
Copy link
Collaborator

Choose a reason for hiding this comment

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

no gold files for this test

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's weird, i wonder why the regression test was green

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see issue #38

tests/tests Outdated
[./TestBasicEventScheduler]
type = 'RavenFramework'
input = 'test_basicEventScheduler.xml'
OrderedCsv = 'basicEventScheduler/Print_sim_HS_0.csv'
Copy link
Collaborator

Choose a reason for hiding this comment

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

the csv file is missed in the gold folder

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

Copy link
Collaborator

Choose a reason for hiding this comment

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

change OrderedCsv to csv, otherwise, the test will be be tested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

"""
This method generate an historySet from the a pointSet which contains initial and final time of the
basic events
@ In, inputDataset, dict, dictionary of inputs from RAVEN
Copy link
Collaborator

Choose a reason for hiding this comment

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

change inputDataset to inputs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

basic events
@ In, inputDataset, dict, dictionary of inputs from RAVEN
@ In, container, object, self-like object where all the variables can be stored
@ Out, basicEventHistorySet, Dataset, xarray dataset which contains time series for each basic event
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is no return for the run method. I think you can move the above line to the method docstring explanation part.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

Comment on lines 65 to 66
elif child.tag == 'variables':
variables = [str(var.strip()) for var in child.text.split(",")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

The variables is not directly used in this class, you probably can remove these lines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The lines are needed as part of the external model class which require the "variables" node

Copy link
Collaborator

Choose a reason for hiding this comment

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

The variables are processed in ExternalModel class, but you are not using it in your class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed lines 65 and 66 but it errors out of line 68

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right. We are looping over all nodes, even if they have already processed by other class. I'm ok to keep it here.


This model is designed to read the initial and final time under which a set of basic events
are set to True, and then it generates an HistorySet with the full temporal profile of all
basic events.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommend to add another paragraph to explain the structure of generated history set.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

for key in container.basicEvents.keys():
tin = inputs[container.basicEvents[key][0]][0]
tend = inputs[container.basicEvents[key][1]][0]
indexes = np.where(np.logical_and(timeArrayCleaned>tin,timeArrayCleaned<=tend))
Copy link
Collaborator

Choose a reason for hiding this comment

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

why 'timeArrayCleaned>tin', but not 'timeArrayCleaned>=tin'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is due to to the conversion from interval-based data to instant-based data (i.e., the history set). The convention here is that a logical value set to 1 at a specific time instant implies that the basic event was actually True from the previous time instant

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see your point, it is better to clarify it in the user manual.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree, added text.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the definition, 'tin' is the initial time for the basic event. Based on the calculation np.where(np.logical_and(timeArrayCleaned>tin,timeArrayCleaned<=tend)), when the time instant is tin, the value are set to 0. Does this mean the event are still the same as before at tin, and does not change state at tin? Only the time large than tin, the basic event are actually changing state. Do I state correctly? @mandd

@mandd
Copy link
Collaborator Author

mandd commented Jul 26, 2021

@wangcj05 : let me know if you need more edit form me here

Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

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

This PR is good. @mandd Could you resolve the conflict in the tests file?

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.

Basic Event Scheduler Model
2 participants