diff --git a/src/NanoParticleTools/analysis/simulation_replayer.py b/src/NanoParticleTools/analysis/simulation_replayer.py index 21ad18c..921acd0 100644 --- a/src/NanoParticleTools/analysis/simulation_replayer.py +++ b/src/NanoParticleTools/analysis/simulation_replayer.py @@ -164,9 +164,10 @@ def update_state(self, states, row, state_map_species_id): current_left_state = states[seed][acceptor_i][state_map_species_id[ _interaction['species_id_2']][_interaction['left_state_2']]] - current_right_state = states[seed][acceptor_i][state_map_species_id[ - _interaction['species_id_2']][_interaction['right_state_2']]] - + current_right_state = states[seed][acceptor_i][ + state_map_species_id[_interaction['species_id_2']][ + _interaction['right_state_2']]] + if current_left_state == 1 and current_right_state == 0: states[seed][acceptor_i][state_map_species_id[_interaction[ 'species_id_2']][_interaction['left_state_2']]] = 0 @@ -177,8 +178,8 @@ def update_state(self, states, row, state_map_species_id): print('current right state', current_right_state) print(states) raise RuntimeError('Inconsistent simulation state encountered.' - 'Please rerun the simulation. If this issue' - 'persists, please raise a github issue') + 'Please rerun the simulation. If this issue' + 'persists, please raise a github issue') def save_populations(self, states, seed, time, x, population_evolution, site_evolution, step_size): diff --git a/src/NanoParticleTools/flows/jobs.py b/src/NanoParticleTools/flows/jobs.py index 417f414..a1a59e6 100644 --- a/src/NanoParticleTools/flows/jobs.py +++ b/src/NanoParticleTools/flows/jobs.py @@ -102,7 +102,7 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint], all_tables_exist, missing = tables_exist(cur, expected_tables) if not all_tables_exist: LOGGER.info(f'Existing run found, but missing {missing} table.' - f'Re-initializing the simulation') + f'Re-initializing the simulation') fresh_start = True cur.close() @@ -115,7 +115,7 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint], all_tables_exist, missing = tables_exist(cur, expected_tables) if not all_tables_exist: LOGGER.info(f'Existing run found, but missing {missing} table.' - f'Re-initializing the simulation') + f'Re-initializing the simulation') fresh_start = True # # Check the number of sites # num_dopant_site_db = len(list(cur.execute('SELECT * from sites'))) @@ -144,32 +144,36 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint], table_exist, _ = tables_exist(cur, ['interupt_state']) if not table_exist: - LOGGER.info('creating interupt_state and interupt_cutoff table') + LOGGER.info( + 'creating interupt_state and interupt_cutoff table') cur.execute(create_interupt_state_sql) cur.execute(create_interupt_cutoff_sql) cur.close() else: - LOGGER.info( - 'Existing run found, but some files are missing. ') + LOGGER.info('Existing run found, but some files are missing. ') fresh_start = True if fresh_start or os.path.exists(output_dir) is False: if override or os.path.exists(output_dir) is False: LOGGER.info('Writing new input files') # Generate Nanoparticle - nanoparticle = DopedNanoparticle(constraints, dopant_specifications, - doping_seed, prune_hosts=True) + nanoparticle = DopedNanoparticle(constraints, + dopant_specifications, + doping_seed, + prune_hosts=True) nanoparticle.generate() # Initialize Spectral Kinetics class to calculate transition rates dopants = [ - Dopant(key, concentration) - for key, concentration in nanoparticle.dopant_concentrations().items() + Dopant(key, concentration) for key, concentration in + nanoparticle.dopant_concentrations().items() ] - spectral_kinetics = SpectralKinetics(dopants, **spectral_kinetics_args) + spectral_kinetics = SpectralKinetics(dopants, + **spectral_kinetics_args) # Create an NPMCInput class - npmc_input = NPMCInput(spectral_kinetics, nanoparticle, initial_states) + npmc_input = NPMCInput(spectral_kinetics, nanoparticle, + initial_states) # Write files _initial_state_db_args = { @@ -226,9 +230,11 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint], if 'simulation_time' in npmc_args.keys(): for seed, simulation_time in data[0].items(): if simulation_time < npmc_args['simulation_time']: - raise RuntimeError(f'Run did not successfully complete.' - f' Simulation {seed} did not complete. Simulated' - f' {simulation_time} s of {npmc_args["simulation_time"]} s') + raise RuntimeError( + f'Run did not successfully complete.' + f' Simulation {seed} did not complete. Simulated' + f' {simulation_time} s of {npmc_args["simulation_time"]} s' + ) # get population by shell diff --git a/tests/inputs/test_nanoparticle.py b/tests/inputs/test_nanoparticle.py index 48fb96f..15848d4 100644 --- a/tests/inputs/test_nanoparticle.py +++ b/tests/inputs/test_nanoparticle.py @@ -147,7 +147,7 @@ def test_serialization(): dopants = [(0, 0.1, 'Na', 'Y'), (0, 0.2, 'Yb', 'Y')] dnp = DopedNanoparticle(constraints, dopants) dnp.generate() - + dnp_dict = dnp.as_dict() dnp_copy = DopedNanoparticle.from_dict(dnp_dict)