Skip to main content

Connector for viewing results from ReMKiT-1D simulations in Simvue.

Project description

Simvue Connectors - ReMKiT-1D


Simvue

Allows simple connection between Simvue and ReMKiT-1D (Reactive Multifluid and Kinetic Transport in 1D), allowing for easy tracking and monitoring of tokamak scrape-off layer simulations in real time.

WebsiteDocumentation

Implementation

A customised RemkitRun class has been created which automatically does the following:

  • Uploads your ReMKiT-1D config file as an input artifact
  • Uploads information from the config file as metadata
  • Tracks the ReMKiT simulation itself, alerting the user via the web UI if the simulation crashes unexpectedly
  • Tracks the outputs from the simulation as they are created, uploading them as 1D, 2D or 3D metrics
  • Uploads all results as output artifacts

The RemkitRun class also inherits from the Run class of the Simvue Python API, allowing for further detailed control over how your simulation is tracked.

Installation

To install and use this connector, first create a virtual environment:

python -m venv venv

Then activate it:

source venv/bin/activate

And then use pip to install this module:

pip install simvue-remkit

Configuration

The server URL and token can be defined as environment variables:

export SIMVUE_URL=...
export SIMVUE_TOKEN=...

or a simvue.toml file can be created containing:

[server]
url = "..."
token = "..."

The exact contents of both of the above options can be obtained directly by clicking the Create new run button on the web UI. Note that the environment variables have preference over the config file.

Usage example

from simvue_remkit.connector import RemkitRun

...

if __name__ == "__main__":

    ...

    # Using a context manager means that the status will be set to completed automatically,
    # and also means that if the code exits with an exception this will be reported to Simvue
    with RemkitRun() as run:

        # Specify a run name, along with any other optional parameters:
        run.init(
          name = 'my-remkit-simulation',                                  # Run name
          metadata = {'simulation_type': 'kinetic_advection'},            # Metadata
          tags = ['remkit', 'advection'],                                 # Tags
          description = 'ReMKiT simulation of tokamak scrape off layer.', # Description
          folder = '/remkit/kinetic-advection/trial_1'                    # Folder path
        )

        # Set folder details if necessary
        run.set_folder_details(
          metadata = {'simulation_type': 'kinetic_advection'},             # Metadata
          tags = ['remkit'],                                               # Tags
          description = 'ReMKiT simulations of tokamak scrape off layers'  # Description
        )

        # Can use the base Simvue Run() methods to upload extra information, eg:
        import os
        run.save_file(os.path.abspath(__file__), "code")

        # Launch the ReMKiT simulation
        run.launch(
            remkit_executable_path='path/to/remkit/executable',  # Path to your ReMKiT executable
            config_path='path/to/my/config_file.json',           # Path to the config file for this simulation
            vars_to_track=['T', 'f'],                            # Optional, specify a set of variables to track
            results_dir_path='path/to/my/results_dir',           # Optional, set a results directory for this run
            clean_results_dir=True                               # Optional, whether to clear pre-existing results before running
            )

You can also use the connector to load in results from previous simulations:

from simvue_remkit.connector import RemkitRun

...

if __name__ == "__main__":

    with RemkitRun() as run:

        # Specify a run name, along with any other optional parameters:
        run.init(
          name = 'my-remkit-simulation',                                  # Run name
          metadata = {'simulation_type': 'kinetic_advection'},            # Metadata
          tags = ['remkit', 'advection'],                                 # Tags
          description = 'ReMKiT simulation of tokamak scrape off layer.', # Description
          folder = '/remkit/kinetic-advection/trial_1'                    # Folder path
        )

        # Can use the base Simvue Run() methods to upload extra information, eg:
        run.save_file(os.path.abspath(__file__), "code")

        # Load from a directory of results from a previous ReMKiT simulation
        run.load(
            results_dir_path='path/to/my/results_dir',  # Path to a directory of results from a ReMKiT simulation
            config_path='path/to/my/config_file.json',  # Optional, path to the config file for this simulation
            vars_to_track=['T', 'f'],                   # Optional, specify a set of variables to track
            )

License

Released under the terms of the GPL-3.0 license.

Citation

To reference Simvue, please use the information outlined in this citation file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simvue_remkit-1.0.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simvue_remkit-1.0.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file simvue_remkit-1.0.0.tar.gz.

File metadata

  • Download URL: simvue_remkit-1.0.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.14

File hashes

Hashes for simvue_remkit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 da356b1d5cbb6ffcc11cdabe7294de11127374957925043e414090257f83b3a1
MD5 c435d8790bdbd56ab3689b4f493c68e0
BLAKE2b-256 57318ca09e1ee096816ca973d9ec2ee492f9c5cf8c7da5e800951cd62687fea9

See more details on using hashes here.

File details

Details for the file simvue_remkit-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: simvue_remkit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.14

File hashes

Hashes for simvue_remkit-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d3145f3855cd8c102010252a51f528ab9419ed87205945b17da3ed11c77d092
MD5 487a009790293bdb3fa1dc0b694c564c
BLAKE2b-256 b9e6645acde446475001dfd5e59bfc268aab8c2e551e816b395ca85651dd5006

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page