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

Feature: state saving #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kostergroup
Copy link

Dear Mike,

Here are the changes we implemented in Excimontec to allow state saving. There are some changes to be made before we can merge as for example, the tests do not currently run as we added the random seed to the OSC_Sim::init() function. Also the changelog still has to be modified and a test is still to be written for the import and export occupancy functions.

The code does run without problems on our cluster as is.

I would very much like to hear your opinion on our changes and your ideas on what we should add before we can merge to the main repository.

Kind regards,
Marten

- Updated copyright for all files changed in this PR
- Removed testing files energies_missing_data and energies_missing_dims because these are now generated automatically during the testing process
- Added parameters_v1.0.txt to the test dir to be used to test parameter file format from v1.0

parameters_default.txt
- Updated parameter list include State_saving_interval parameter that determines how often the state is saved during the equilibration phase of the steady transport test
- Fixed issue with how the site energy file is designated for importing site energies

main.cpp
- Moved all of the command line parsing code to the Parameters class
- Moved the procid and generator seed variables to the Parameters class
- Moved the site energies export to the OSC_Sim class
- Moved the state saving code to the OSC_Sim class

OSC_Sim class
- Updated init method to set the generator seed
- Updated init method to import energies when resuming the steady transport test in enabled
- Updated init method to export the site energies when starting the steady transport test and to initiate resuming from an existing state file
- Added checkSTTStateFile method to check the validity of a steady transport test state file
- Updated exportEnergies method to output a comment at the top of the file that provides information about the model used to generate the site energies
- Combined exportEnergies methods to a single method where the output of absolute or relative site energies is now controlled by a boolean input parameter
- Replaced exportOccupancy method with the exportSteadyTransportTestState method which now writes the state of the lattice occupancy to a text file in a compressed format and handles creation of a backup state file
- Updated generateSteadyPolarons to remove code that parses the occupancy state file
- Refactored the initializeArchitecture method to extract out a separate importEnergies method
- Added resumeSteadyTransportTest method that parses the state file and create polarons on the sites indicated from the lattice occupancy data
- Updated updateSteadyData method to handle periodic state saving during the equilibration phase of the steady transport test

Parameters class
- Added Enable_resume_stt parameter to turn on resuming of the steady transport test
- Removed the Enable_export_occupancies parameter since this featuer is now always enabled
- Removed Keep_only_newest_occupancy because the default behavior is to now keep only two state files, the latest one and the previous one as a backup
- Renamed Output_interval to State_saving_interval to be more explicit about what the parameter does
- Replaced Energies_import_filename and Energies_export_filename with Energies_import_format and Energies_export_format to allow format specification that allows separate files to be loaded for each processor
- Replaced Occupancies_import_filename and Occupancies_export_filename with a single parameter STT_state_file_format the defines the default file naming format to be used for both export and import
- Added Proc_ID, Version_str, and Generator_seed, and Parameters_filename parameters so that all of these variables are accessing to the OSC_Sim class through the Parameters class
- Updated importParameters method to no longer have the input parameter file stream and instead import the parameters from the file indicated by the Parameters_filename variable
- Updated importParameters method to check the version of the parameter file from the parameter file comment line and parse lines accordingly
- Updated importParameters method to import the parameters in the latest parameter file and remove import lines for the parameter variables that were removed from the class
- Added parseCommandLineArguments method to parse the command line arguments and set the parameter variables acoordingly
- Updated checkParameters method to check the validity of the State_saving_interval

test.cpp
- Updated all test methods to use the new OSC_Sim init method
- Added default definition for the STT_state_file_format. Energies_import_format, and Energies_export_format parameters
- Added ParseArgumentTests to test this new method
- Updated ParameterTests to test new importParameters method
- Added test to SetupTests to check that setting the generator seed works properly
- Renamed EnergiesImportTests to EnergiesExportImportTests and added test for exporting site energies as well
- Updated EnergiesExportImportTests to use new default file naming format site_energies_#.txt
- Updated EnergiesExportImportTest to ignore comment lines in the site energies files
- Added test to SteadyTransportTests to test resuming a previously started steady transport test
@MikeHeiber
Copy link
Owner

I did a major refactor and got everything working now in preparation to get this into a v1.1 beta release. It would be good if you could test out this new version on your cluster to make sure it works well.

Right now the generator seed is set via command line arguments like so,
Excimontec.exe parameters.txt -seed 100
which sets the seed to 100. Enabling a steady transport test to be resumed is also done via command line argument. Running a steady transport test will automatically create a site energy file and state files during the equilibration phase. The occupancy information in the state file is compressed using run length encoding so they take fairly little space and don't use much IO. You can adjust the state saving interval in the parameter file to your liking, but a value of 10,000 events is used by default. You can resume a steady transport test by having the state files (STT_equilibration_state_#latest.txt) and the site energies files (site_energies#.txt) in the working directory and restarting the simulation like so
Excimontec.exe parameters.txt -seed 100 -resume_stt
When resuming the simulation, it will start where it left off in the equilibration phase and continue the steady transport test. You do not need to worry about if the processors get out of sync since they will each get resumed and continue to the same stopping condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants