/Deep-Lynx-MOOSE

The Deep Lynx MOOSE Adapter connects the Deep Lynx data warehouse with any MOOSE executable. The Adapter can receive events from Deep Lynx and will take incoming data to format a template input file for the MOOSE executable. Returns from the MOOSE run are sent back to Deep Lynx for use by other applications.

Primary LanguagePythonOtherNOASSERTION

MOOSE Adapter

Overview of the Deep Lynx MOOSE Adapter

The Deep Lynx MOOSE Adapter connects the Deep Lynx data warehouse with any MOOSE executable. A template input file is used to generate a configuration file that specifies the parameters that can be changed in an input file. The Adapter receives events from Deep Lynx, verifies the incoming data with a configuration file, and modifies a template input file for the MOOSE executable. Returns from the MOOSE run are sent back to Deep Lynx for use by other applications.

Template Parser

The purpose of the Template Parser file is to creates a configuration file that specifies...

  1. The variables that can be changed in the input file
  2. Expected datatype for the variable

The Template Parser can generate a configuration file via the command line or environment variables (.env file).

Steps

  1. Create template input file
    • Add # {{config}} tag to each parameter to change in the MOOSE input file
  2. Run script
    • Environment variables
      • Specify the path to TEMPLATE_INPUT_FILE_NAME
      • Specify the path to the CONFIG_FILE_NAME that will be generated by the Template Parser
    • Command Line Interface
      # Sample command
      python adapter/template_parser.py -i data/example/config_input_file.i
      
      Options:
      -i <input_file>  Specify a MOOSE input file
      -h, --help       Displays CLI usage statement
      
  3. Produces a configuration file (.cfg)

Configuration File Format

  • Node path in the brackets
  • List the parameter and its datatype for each node
[root]
xmax = int

[/Mesh/gen]
dim = int
nx = int
xmax = int

Edit Input File

The purpose of the Edit Input File file is to create the input file to run in MOOSE. The template input file is updated using new incoming data from Deep Lynx.

Steps

  1. Create a configuration file via the Template Parser
  2. Verify the parameters in the input file can be changed through the configuration file
  3. Updates the parameter value of a node and adds a comment documenting the change
  4. Remove the {{config}} comments from the parameters of a node from the template input file
  5. Writes a new input file with the incorporated changes to RUN_FILE_NAME

MOOSE Adapter

The purpose of the MOOSE Adapter file is to run an input file in MOOSE.

Steps

  1. Receive new data from Deep Lynx
    • Edit the input file via Edit Input File file
  2. Run the input file in MOOSE
    • Inputs: data file and input file
    • Outputs: results file
  3. Imports the results into Deep Lynx

MOOSE Adapter Architecture

Environment Variables (.env file)

To run this code, first copy the .env_sample file and rename it to .env. Several parameters must be present:

  • DEEP_LYNX_URL: The base URL at which calls to Deep Lynx should be sent
  • CONTAINER_NAME: The container name within Deep Lynx
  • DATA_SOURCE_NAME: A name for this data source to be registered with Deep Lynx
  • DATA_SOURCES: A list of Deep Lynx data source names which listens for events
  • TEMPLATE_INPUT_FILE_NAME: The .i template input file name to look for
  • CONFIG_FILE_NAME: The .cfg configuration file name to look for
  • RUN_FILE_NAME: The .i input file name to run in MOOSE
  • QUEUE_FILE_NAME: The name of the queue file that is updated with new data via the Deep Lynx event system
  • QUEUE_LENGTH: The maximum length of the queue which updates data in First-In-First-Out (FIFO) data structure
  • METADATA_FILE_NAME: The Deep Lynx metadata file name used in the typemapping system of Deep Lynx
  • PYTHONPATH: The path to the local MOOSE python folder
  • MOOSE_OPT_PATH: The path to the local MOOSE executable
  • IMPORT_FILE_WAIT_SECONDS: the number of seconds to wait between attempts to find the MOOSE output file to import into Deep Lynx
  • REGISTER_WAIT_SECONDS: the number of seconds to wait between attempts to register for events

Logs will be written to a logfile, stored in the root directory of the project. The log file name is set in main() of moose_adapter.py.

Getting Started

  • Complete the Poetry installation
  • All following commands are run in the root directory of the project:
    • Run poetry update to install the defined dependencies for the project.
    • Run poetry shell to spawns a shell.
    • Finally, run the project with the command flask run

Logs will be written to a log file, stored in the root directory of the project. The log filename is set in adapter/__init__.py and is called MOOSEAdapter.log.

MOOSE Installation

  • Complete the MOOSE installation
  • Complete the setup for the MOOSE Python Tools
    • Add export PYTHONPATH=$PYTHONPATH:~/projects/moose/python to your bash environment

MOOSE Dependencies

The MOOSE Adapter uses the pyhit and moosetree modules within MOOSE. For more information, visit the Helpful Links section.

Contributing

This project uses yapf for formatting. Please install it and apply formatting before submitting changes.

  1. poetry shell
  2. yapf --in-place --recursive . --style={column_limit:120})

Helpful Links

Other Software

Idaho National Laboratory is a cutting edge research facility which is a constantly producing high quality research and software. Feel free to take a look at our other software and scientific offerings at:

Primary Technology Offerings Page

Supported Open Source Software

Raw Experiment Open Source Software

Unsupported Open Source Software

License

Copyright 2021 Battelle Energy Alliance, LLC

Licensed under the LICENSE TYPE (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/MIT

Unless required by applicable law or agreed to in writing, software 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.

Licensing

This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

Developers

By contributing to this software project, you are agreeing to the following terms and conditions for your contributions:

You agree your contributions are submitted under the MIT license. You represent you are authorized to make the contributions and grant the license. If your employer has rights to intellectual property that includes your contributions, you represent that you have received permission to make contributions and grant the required license on behalf of that employer.