-
Notifications
You must be signed in to change notification settings - Fork 0
Isaac 2025 Work Package #15
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
Open
iomags2211
wants to merge
49
commits into
main
Choose a base branch
from
dev2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
bdb3495
Initial files
iomags2211 efdcf6e
Files to simulate ground truth and generate perturbed datasets, with …
iomags2211 e05fc35
Upload .json files for perturbed geometry and boundary conditions dat…
iomags2211 f4aa1d1
Restructured to separate 2D and 3D sims
iomags2211 bc43e54
Generating datasets for training and validation and starting to build…
iomags2211 73e519b
Removed errors from thermocouples
iomags2211 d8fe7a4
Attempting to get everything together into a single script
iomags2211 5242f02
Finished script that uses tkinter to provide a UI, and moved non-tkin…
iomags2211 569a86b
Deleted example datasets
iomags2211 c045608
Added docstrings
iomags2211 5b17cc6
Exception handling and sanitising user inputs
iomags2211 87692f7
Restructured to standard Python project with classes and packaged for…
iomags2211 36b389e
Added monoblock script to correct folder
iomags2211 4ff767b
Renamed example files
iomags2211 53b64ae
First batch of updates following code review
iomags2211 9e15d63
Final improvements from code review + added other frameworks + starte…
iomags2211 fc2dd13
Create docs/requirements.txt
iomags2211 608500b
Delete docs directory
iomags2211 e69edfb
Updated next steps
iomags2211 3b93e67
Added pyvale to dependencies
iomags2211 22127e6
Removed pyvale from dependencies
iomags2211 ab7812b
Removed pyvale from dependencies
iomags2211 2ddcd56
Added output structure and requirements.txt
iomags2211 08eaba7
Improved exception handling
iomags2211 0a3022c
Added fully configureable example (no convenience functions)
iomags2211 5706b8c
Added more comments to fully configureable example
iomags2211 05e463d
Added tests for MooseSetup
iomags2211 5d580c4
Changed the way the sensor type is defined
iomags2211 73fbed0
Improved user control over the framework + hyperparameters
iomags2211 f46462f
Minor changes
iomags2211 9a407c8
Simplified and streamlined model building, added headers to labelled …
iomags2211 3b4c97b
Generalised labelled dataset header
iomags2211 f8a253f
Made tkinter interface optional
iomags2211 c3c4887
Issac 2025 Work Package
lukethehuman 2b7ca8e
Updated to match updates to pyvale
iomags2211 5f17c52
Updated to match updates to pyvale
iomags2211 bbfe260
🔥 Delete (untrack) egg-info file
lukethehuman a825b38
🙈 Update .gitignore to pythonproject template
lukethehuman 711daf3
🙈 Add examples/example_outputs to .gitignore
lukethehuman af9c725
🚛 Merge pyproject.toml files
lukethehuman 042439a
Update src/icarus/__init__.py
iomags2211 5d88be0
Update src/icarus/datasetgenerator.py
iomags2211 a8fd232
Update src/icarus/userinterface.py
iomags2211 19f43ee
Deleted src/icarus.egg-info/PKG-INFO
iomags2211 dc250ca
Changes from pull request
iomags2211 69aa8b2
Changes from pull request
iomags2211 565f2ec
Deleted superfluous files and folders
iomags2211 3a37fb1
Removed moose-config.json to untrack
iomags2211 a407882
Untracked moose-config.json
iomags2211 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,62 @@ | ||
| # icarus | ||
| Machine learning for fusion simulation validation. | ||
| # Icarus | ||
|
|
||
| A fully customisable set of simulation-driven machine learning tools that interacts with MOOSE and can be used to assess the agreement between an experiment and simulation; that is, to validate the simulation with experimental data and provide the engineer with a probable reason for any mismatches to allow further investigation and diagnosis. | ||
|
|
||
| ## Installation | ||
| ### Virtual Environment | ||
|
|
||
| Icarus is intended for use in a virtual environment. You can create a new virtual environment with | ||
|
|
||
| ``` | ||
| python -m venv venv | ||
| ``` | ||
|
|
||
| and activate it with | ||
| ``` | ||
| source venv/bin/activate | ||
| ``` | ||
|
|
||
| ### Standard & Developer Installation | ||
|
|
||
| Clone `icarus` to your local system along with submodules using | ||
|
|
||
| ``` | ||
| git clone --recurse-submodules git@github.com:aurora-multiphysics/icarus.git | ||
| ``` | ||
|
|
||
| `cd` to the root directory of `icarus` and run | ||
| ``` | ||
| pip install . | ||
| ``` | ||
|
|
||
| Alternatively, to create an editable/developer installation of `icarus` | ||
| ``` | ||
| pip install -e . | ||
| ``` | ||
|
|
||
| ### MOOSE App | ||
|
|
||
| `icarus` is intended for use with any MOOSE app | ||
| It has been developed and tested using the `proteus` MOOSE app which can be found here: https://github.com/aurora-multiphysics/proteus. Follow the build instructions found on this page to install `proteus`. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| The examples folder shows how to use `icarus` for different input files and with different levels of user control. Make sure to include a moose_config.json file wherever you run it, and change the values contained to match your system. | ||
|
|
||
| Icarus requires a moose_config.json file to be present wherever it is run; if there is not one already present, it will create one with the following values: | ||
| ``` | ||
| { | ||
| "main_path": "path/to/moose", | ||
| "app_path": "path/to/YourMooseApp", | ||
| "app_name": "YourMooseApp-opt" | ||
| } | ||
| ``` | ||
|
|
||
| Make sure to change these values to match your system before running Icarus. | ||
|
|
||
| ## Contributors | ||
|
|
||
| - Isaac Magee, UK Atomic Energy Authority, (iomags2211) | ||
| - Lloyd Fletcher, UK Atomic Energy Authority, (TheScepticalRabbit) | ||
| - Luke Humphrey, UK Atomic Energy Authority, (lukethehuman) | ||
|
|
iomags2211 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| """ | ||
| Example file showing how to use Icarus and detailing customisable options. | ||
|
|
||
| This example runs an input file to produce a 2D temperature field with | ||
| different parameters perturbed. Any results from the default input file | ||
| are considered valid, while any other results are invalid. The datasets | ||
| generated are split into training and validation datasets and labelled, | ||
| and then a machine learning model is trained using the training dataset | ||
| to distinguish between valid and invalid datasets (and classify the | ||
| invalid sets depending on which parameter has been altered, if desired). | ||
| The model is then validated using the validation datasets to see if it | ||
| correctly predicted the labels. | ||
|
|
||
| (c) Copyright UKAEA 2025. | ||
| """ | ||
|
|
||
| import sklearn | ||
| from icarus import (DatasetGenerator, | ||
| ModelBuilder) | ||
|
|
||
|
|
||
| def main(): | ||
| """Run all of the other functions. | ||
| """ | ||
| # Required parameters - change to desired values | ||
|
|
||
| # Input and output paths | ||
| input_file_path = "scripts/moose/plate_2d_thermal.i" | ||
| output_file_path = "examples/example_outputs/ex1_outputs/" | ||
|
|
||
| # Perturbation parameters, leave blank (ie parameters = {}) to use | ||
| # auto-generated tkinter interface | ||
| # Format as {param_name, [param_class, [param_values]]} | ||
| # where param_name is the name of the parameter from the input file | ||
| # param_class is the classification of the parameter | ||
| # geom - geometry, bc - boundary condtion, mat_prop - material property | ||
| # and param_values is a list of values the parameter should take on | ||
| parameters = { | ||
| "max_temp": ["bc", [750, 1000, 1250, 1500, 1750]], | ||
| "thermal_conductivity": ["mat_prop", [55, 65, 76, 85, 95]] | ||
| } | ||
|
|
||
| # Number of validation values to use for each parameter, respectively. | ||
| # This defines how many different perturbed values each parameter will | ||
| # take to create validation datasets to assess the quality of the model. | ||
| num_validation_values = [3, 3] | ||
|
|
||
| # Parallelisation options | ||
| n_tasks, n_threads = 1, 2 # Parallelisation of each simulation | ||
| num_para_runs = 2 # Number of concurrent simulations | ||
|
|
||
| # Ratio of invalid:valid datasets | ||
| # This defines how many datasets will be generated from the default | ||
| # input file (no perturbations -> labelled 0 for valid dataset), | ||
| # as the right ratio is important to ensure the model can recognise | ||
| # a valid dataset without assuming all datasets are valid. | ||
| datasets_per_ground_truth = 3 | ||
|
|
||
| # Modelling parameters - change to desired values: | ||
|
|
||
| # Classifier framework | ||
| # For a comprehensive list of available classifiers, please refer | ||
| # to the relevant documentation: | ||
| # https://scikit-learn.org/stable/supervised_learning.html | ||
| classifier_framework = sklearn.ensemble.RandomForestClassifier | ||
iomags2211 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Classifier parameters | ||
| # Note that not all parameters are required for every classifier. | ||
| # Any irrelevant or unsupported parameters for the selected model | ||
| # will be automatically ignored during model creation. | ||
| # For a comprehensive list of available parameters for each classifier, | ||
| # please refer to the relevant documentation: | ||
| # https://scikit-learn.org/stable/modules/classes.html#classifier | ||
| classifier_params = { | ||
| "n_estimators": 100, | ||
| "random_state": 42, | ||
| "kernel": "linear", | ||
| "C": 0.025, | ||
| "max_depth": 5 | ||
| } | ||
|
|
||
| # The field being analysed as used by your input script | ||
| field_key = "temperature" | ||
|
|
||
| # Analysis sensor type | ||
| # (thermocouples for temperature, disp_sensors for displacement, | ||
| # or strain_gauges for strain) | ||
| sensor_type = "thermocouples" | ||
|
|
||
| # Sensor arrangement (x_sensors, y_sensors, z_sensors) | ||
| # Defines how many sensors are present in each dimension, | ||
| # with sensors being uniformly distributed. | ||
| # e.g. (3,2,1) would result in a 2D arrangement as follows: | ||
| # _______________ | ||
| # | | | ||
| # | x x x | | ||
| # | x x x | | ||
| # |_______________| | ||
| sensors = (3, 2, 1) | ||
|
|
||
| # Number of spatial dimensions being used | ||
| dims = 2 | ||
|
|
||
| # Whether the sensors should include errors or give exact values. | ||
| # Including errors means the model is more likely to miscategorise, | ||
| # but a successful model will be much better in reality, where errors | ||
| # are unavoidable. | ||
| errors = False | ||
|
|
||
| # Whether the model should be a multi-classifier rather than binary, | ||
| # so it can distinguish between perturbations to different classes of | ||
| # invalid parameters (geometry, BCs, material properties) rather than | ||
| # just valid and invalid results | ||
| multi = True | ||
|
|
||
| # Whether the unlabelled data should be deleted | ||
| delete_datasets = False | ||
|
|
||
| # Whether the model should be saved as a .pkl file | ||
| # and what it should be called | ||
| save = False | ||
| model_name = "ex1_2d_model" | ||
iomags2211 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Initialise dataset generator to generate unlabelled datasets | ||
| dataset_generator = DatasetGenerator(input_file_path, | ||
| n_tasks, n_threads, | ||
| parameters, num_validation_values, | ||
| datasets_per_ground_truth, | ||
| output_file_path, | ||
| num_para_runs) | ||
|
|
||
| # Generate the unlabelled perturbed, validation and ground truths datasets | ||
| dataset_generator.generate_datasets() | ||
|
|
||
| # Initialise model builder to set up, run, and (optionally) | ||
| # save the chosen model | ||
| model = ModelBuilder(output_file_path, field_key, sensor_type, sensors, | ||
| dims, errors, multi, delete_datasets, save) | ||
|
|
||
| # Set up, run, and (optionally) save the chosen model | ||
| model.build_model(classifier_framework, classifier_params, model_name) | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.