{"id":20520247,"url":"https://github.com/plasmacontrol/plasmaevolution","last_synced_at":"2025-08-11T00:48:49.703Z","repository":{"id":83538823,"uuid":"594066788","full_name":"PlasmaControl/PlasmaEvolution","owner":"PlasmaControl","description":"Predict tokamak plasma state evolution over time (new version of ProfilePredictor associated with Abbate/Conlin/etc. 2021 Nucl. Fusion 61 046027)","archived":false,"fork":false,"pushed_at":"2025-04-08T21:28:07.000Z","size":4582,"stargazers_count":6,"open_issues_count":8,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-14T02:13:13.732Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlasmaControl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-27T14:21:27.000Z","updated_at":"2025-04-11T15:32:25.000Z","dependencies_parsed_at":"2023-11-29T18:29:04.443Z","dependency_job_id":"84788120-3e89-4589-8bc8-bb0d052a52bd","html_url":"https://github.com/PlasmaControl/PlasmaEvolution","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PlasmaControl/PlasmaEvolution","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaControl%2FPlasmaEvolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaControl%2FPlasmaEvolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaControl%2FPlasmaEvolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaControl%2FPlasmaEvolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlasmaControl","download_url":"https://codeload.github.com/PlasmaControl/PlasmaEvolution/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaControl%2FPlasmaEvolution/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269814220,"owners_count":24479355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T22:18:49.834Z","updated_at":"2025-08-11T00:48:49.432Z","avatar_url":"https://github.com/PlasmaControl.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repo trains and analyzes neural nets for predicting how a tokamak (fusion reactor) plasma will evolve in time given an initial condition and user-specified actuator trajectories. It is a (pytorch-based) cleanup of the (tensorflow-based) [plasma-profile-predictor](https://github.com/PlasmaControl/plasma-profile-predictor), which was described in our [2021 Nuclear Fusion paper](https://doi.org/10.1088/1741-4326/abe08d).\n\nGenerate an h5 file with [data-fetching repo](https://github.com/PlasmaControl/data-fetching)\n\n-------- TO TRAIN A MODEL ---------\nIn configs/default.cfg point raw_data_filename to the generated h5 file. Then change preprocessed_data_filename_base to a \"base\" name for writing processed data. Run preprocess_data.py, which will generate the basename with _train.pkl, _val.pkl, and _test.pkl appended. Change output_dir in the config file to where you want to dump a model, then run python ian_train.py to train a model to go there. To train a full ensemble of models (submitting them to slurm on traverse) do python launch_ensemble.py which will train 10 with 0,...,9 appended to the end. Use modelStats.py {config_filename} to plot training losses.\n\n-------- TO CREATE AND VISUALIZE MODEL OUTPUTS ---------\nRun SimpleModelRollout.py {config_filename} (where config_filename is the full path to the config file corresponding to the model) to create a pickle file with the predicted profiles. Set plot_ensemble to True or False depending on whether you're doing ensemble modeling or one model at a time. To visualize the predictions, use prediction_plotter.ipynb\n\n-------- TO HELP TEST ---------\nSet train_shots, val_shots, and test_shots to a small number of shots each\n\n-------- TO TUNE MODELS -------\nTraining takes a long time with curriculum learning.\nIf you have a good model with the right inputs and want to tune it on simulation or other-machine data, or overfit it to data (e.g. for developing control for a specific scenario), copy the config file from the model you like, then\n1) set tune_model to true\n2) set the model_to_tune_filename_base to the output_filename_base (i.e. you're tuning the good model)\n3) set the output_filename_base to your new model name\nIf you only want to tune certain layers add the layer names as a list. In torch layer names correspond to named class variables (self.rnn --\u003e rnn, self.encoder --\u003e encoder, self.decoder --\u003e decoder) and can be found with\nfor name, child in model.named_children():\n    print(name)\n4) for most cases set autoregression_start_epoch and autoregression_end_epoch to 0 since you don't want to go back to the beginning of the curriculum learning, you want to start from what you already have\n5) for some cases (e.g. for training on simulations where you only confidently can predict out to rho=0.8 and you only predict a subset of the profiles like TE and TI) add a list of the profiles you don't want to consider to masked_outputs and set tuning--\u003erho_bdry_index to the index of the boundary (e.g. rho=0.8 for nx=33 would be 0.8*33 ~ 26). This will mask those outputs during training.\n\n-------- LRAN TRAINING AND CONTROL ---------\nTo train a model with latent linear dynamics (LRAN) to be used to control applications, change the model.cfg model_type from IanRNN to HiroLRAN and repeat training steps above. To launch a control simulation, where the controller makes MPC actuator decisions using HiroLRAN and the profile evolution is simulated using IanRNN, use control_simulation.py. To visualize these results use control_plotter.ipynb. \n\n-------- ENVIRONMENT SETUP ---------\nFor pytorch environment setup on PPPL/Princeton's Traverse cluster along with a ton of other helpful info and examples, see [researchcomputing.princeton.edu](https://researchcomputing.princeton.edu/pytorch). h5py is also required for reading the h5 dataset. As of February 2023, I personally use\n    module load anaconda3/2022.5\n    conda create --name torch --channel \"https://opence.mit.edu/#/\" \"pytorch==1.12*=cuda11*\" torchvision\n    conda install -c anaconda h5py\n    conda activate torch\n\nAnd of course reload anaconda and activate this environment every time you go to run the code.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplasmacontrol%2Fplasmaevolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplasmacontrol%2Fplasmaevolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplasmacontrol%2Fplasmaevolution/lists"}