-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from BlauGroup/tests
Add examples and more tests
- Loading branch information
Showing
12 changed files
with
605 additions
and
49 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,193 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Imports" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/Users/sivonxay/opt/anaconda3/envs/npmc_env/lib/python3.10/site-packages/maggma/utils.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", | ||
" from tqdm.autonotebook import tqdm\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from NanoParticleTools.differential_kinetics import get_diff_kinetics_parser, DifferentialKinetics\n", | ||
"from monty.serialization import dumpfn" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"High-throughput rate equation solver uses the maggma builder." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dk = DifferentialKinetics(num_samples=10,\n", | ||
" excitation_power=[1e3, 1e5],\n", | ||
" excitation_wavelength=[800, 980],\n", | ||
" possible_dopants=['Yb', 'Er', 'Nd', 'Tm'],\n", | ||
" max_dopants=3,\n", | ||
" include_spectra=True,\n", | ||
" output_file='out.h5',\n", | ||
" )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now we run the builder. This function call runs each sample sequentially" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"10it [00:00, 6657.63it/s]" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"2023-11-03 15:04:53,807 - DifferentialKinetics - INFO - Processing batch of 1000 items\n", | ||
"2023-11-03 15:05:04,698 - SpectralKinetics - INFO - Found solution in 10.89 seconds\n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/Users/sivonxay/opt/anaconda3/envs/npmc_env/code/NanoParticleTools/src/NanoParticleTools/util/conversions.py:11: RuntimeWarning: divide by zero encountered in divide\n", | ||
" return 1 / wavenumber * 1e7\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"2023-11-03 15:05:16,538 - SpectralKinetics - INFO - Found solution in 11.84 seconds\n", | ||
"2023-11-03 15:05:16,539 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:18,130 - SpectralKinetics - INFO - Found solution in 1.59 seconds\n", | ||
"2023-11-03 15:05:18,159 - SpectralKinetics - INFO - Found solution in 0.03 seconds\n", | ||
"2023-11-03 15:05:18,159 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:18,167 - SpectralKinetics - INFO - Found solution in 0.01 seconds\n", | ||
"2023-11-03 15:05:18,167 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:18,180 - SpectralKinetics - INFO - Found solution in 0.01 seconds\n", | ||
"2023-11-03 15:05:18,180 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:18,185 - SpectralKinetics - INFO - Found solution in 0.01 seconds\n", | ||
"2023-11-03 15:05:19,591 - SpectralKinetics - INFO - Found solution in 1.41 seconds\n", | ||
"2023-11-03 15:05:19,592 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:20,524 - SpectralKinetics - INFO - Found solution in 0.93 seconds\n", | ||
"2023-11-03 15:05:20,524 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:20,985 - SpectralKinetics - INFO - Found solution in 0.46 seconds\n", | ||
"2023-11-03 15:05:20,991 - SpectralKinetics - INFO - Found solution in 0.00 seconds\n", | ||
"2023-11-03 15:05:20,991 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:20,996 - SpectralKinetics - INFO - Found solution in 0.01 seconds\n", | ||
"2023-11-03 15:05:20,996 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:20,998 - SpectralKinetics - INFO - Found solution in 0.00 seconds\n", | ||
"2023-11-03 15:05:27,735 - SpectralKinetics - INFO - Found solution in 6.74 seconds\n", | ||
"2023-11-03 15:05:27,736 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:28,482 - SpectralKinetics - INFO - Found solution in 0.75 seconds\n", | ||
"2023-11-03 15:05:30,691 - SpectralKinetics - INFO - Found solution in 2.21 seconds\n", | ||
"2023-11-03 15:05:30,691 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:05:31,170 - SpectralKinetics - INFO - Found solution in 0.48 seconds\n", | ||
"2023-11-03 15:05:32,975 - SpectralKinetics - INFO - Found solution in 1.80 seconds\n", | ||
"2023-11-03 15:05:55,912 - SpectralKinetics - INFO - Found solution in 22.94 seconds\n", | ||
"2023-11-03 15:06:00,037 - SpectralKinetics - INFO - Found solution in 4.12 seconds\n", | ||
"2023-11-03 15:06:00,037 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:06:01,291 - SpectralKinetics - INFO - Found solution in 1.25 seconds\n", | ||
"2023-11-03 15:06:01,291 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:06:02,131 - SpectralKinetics - INFO - Found solution in 0.84 seconds\n", | ||
"2023-11-03 15:06:02,131 - SpectralKinetics - INFO - Using user input initial population\n", | ||
"2023-11-03 15:06:02,824 - SpectralKinetics - INFO - Found solution in 0.69 seconds\n", | ||
"2023-11-03 15:06:02,827 - h5py._conv - DEBUG - Creating converter from 5 to 3\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"dk.run()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"To parallelize over available cores on a system, we need to use `mrun` from maggma.\n", | ||
"\n", | ||
"First, we dump the builder to json" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dumpfn(dk, 'diff_eq.json')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"To run the builder with 4 parallel workers, invoke the command: `mrun -n 4 diff_eq.json`" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "npmc_env", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.11" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains 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
This file contains 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
This file contains 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.