Skip to content

Commit

Permalink
Merge pull request #11 from lanl/10-provide-the-option-to-specify-the…
Browse files Browse the repository at this point in the history
…-output-folder-other-than-within-the-repository

10 provide the option to specify the output folder other than within the repository
  • Loading branch information
along4 authored Jul 11, 2024
2 parents ec140ed + 60cb725 commit 528bdc9
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 58 deletions.
166 changes: 127 additions & 39 deletions examples/Notebooks/u_fit_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,26 @@
"name": "stdout",
"output_type": "stream",
"text": [
"total 544K\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 .\n",
"drwxr-xr-x 5 l280162 l280162 4.0K Jul 10 13:23 ..\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 .archive\n",
"drwxr-xr-x 2 l280162 l280162 4.0K Jul 10 21:58 images\n",
"-rw-r--r-- 1 l280162 l280162 199K Jul 10 13:23 natEu_fit_tutorial.ipynb\n",
"-rw-r--r-- 1 l280162 l280162 1.5K Jul 10 13:23 nat_europium.ini\n",
"-rw-r--r-- 1 l280162 l280162 319K Jul 10 21:58 u_fit_tutorial.ipynb\n",
"-rw-r--r-- 1 l280162 l280162 1.5K Jul 10 21:58 uranium.ini\n",
"total 16K\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 20:43 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 20:43 ..\n",
"drwxr-xr-x 2 l280162 l280162 4.0K Jul 10 20:43 endf\n",
"drwxr-xr-x 2 l280162 l280162 4.0K Jul 10 20:43 u235-u238\n"
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 ..\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 endf\n",
"drwxr-xr-x 2 l280162 l280162 4.0K Jul 10 22:36 u235-u238\n"
]
}
],
"source": [
"!ls -lah .archive/"
"!ls -lah \n",
"!ls -lah .archive/\n"
]
},
{
Expand Down Expand Up @@ -133,24 +143,27 @@
"name": "stdout",
"output_type": "stream",
"text": [
"total 16K\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 20:43 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 20:43 ..\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 20:43 U235\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 20:43 U238\n"
"total 28K\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 22:37 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 ..\n",
"-rw-r--r-- 1 l280162 l280162 455 Jul 10 22:37 U235.inp\n",
"-rw-r--r-- 1 l280162 l280162 1.8K Jul 10 22:37 U235.out\n",
"-rw-r--r-- 1 l280162 l280162 17 Jul 10 22:37 U235_ENDF-dummy.dat\n",
"lrwxrwxrwx 1 l280162 l280162 74 Jul 10 22:35 res_endf8.endf -> /home/l280162/Programs/PLEIADES/nucDataLibs/resonanceTables/res_endf8.endf\n",
"drwxr-xr-x 2 l280162 l280162 4.0K Jul 10 22:37 results\n"
]
}
],
"source": [
"!ls -lah .archive/endf"
"!ls -lah .archive/endf/U235/"
]
},
{
"cell_type": "markdown",
"id": "c8eb5fc4-3d84-4085-a6d3-b780a288c68b",
"metadata": {},
"source": [
"#### Configure SAMMY for the fit of Natural Eu\n",
"#### Configure SAMMY for the fit of Uranium foil\n",
"\n",
"Now that we have the needed SAMNDF.PAR files for each isotope (stored in the .archive/endf/Eu15* folders) we can configure all the needed SAMMY files to fit a naterual Eu transmission spectrum. \n",
"\n",
Expand All @@ -171,7 +184,8 @@
"Writing output parFile: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238/params.par\n",
"Creating SAMMY inpFile files for isotopes: ['U-235', 'U-238'] with abundances: [0.01, 0.01]\n",
"No config file given. Using default parameters.\n",
"Created compound input file: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238/input.inp\n"
"Created compound input file: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238/input.inp\n",
"Symlinking data file: /home/l280162/Programs/PLEIADES/examples/data/u235-u238.twenty into /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238\n"
]
}
],
Expand All @@ -190,20 +204,43 @@
"Here Pleiades has taken all the needed information from the two (Eu151, Eu153) `SAMNDF.PAR` files and combined them to form a `params.par` file. Additionally Pleiades has created the needed input.inp file to run the natEu SAMMY fit. "
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "86240af4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 40K\n",
"drwxr-xr-x 2 l280162 l280162 4.0K Jul 10 22:37 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 ..\n",
"-rw-r--r-- 1 l280162 l280162 582 Jul 10 22:37 input.inp\n",
"-rw-r--r-- 1 l280162 l280162 23K Jul 10 22:37 params.par\n",
"lrwxrwxrwx 1 l280162 l280162 62 Jul 10 22:37 u235-u238.twenty -> /home/l280162/Programs/PLEIADES/examples/data/u235-u238.twenty\n"
]
}
],
"source": [
"!ls -lah .archive/u235-u238/"
]
},
{
"cell_type": "markdown",
"id": "e5dd59be-27c0-4262-87bd-57d22d2eff63",
"metadata": {},
"source": [
"#### running the SAMMY of Uranium foil\n",
"#### Running the SAMMY fit on the Uranium foil data\n",
"\n",
"Now that everything is set we are prepared to run the actual fit on the natural Eu data. \n",
"Note: You can change the print verbose level to print out important variables and paths. "
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"id": "ac472354-2fba-4c54-bf1d-9706dae063df",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -245,7 +282,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 11,
"id": "0535922c",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -304,7 +341,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 12,
"id": "118e9ae4-bfdc-4aac-8819-5e756a6b2cff",
"metadata": {},
"outputs": [
Expand All @@ -329,16 +366,20 @@
"id": "f134363d",
"metadata": {},
"source": [
"#### Something is missing!\n",
"\n",
"Looking at the plot it appears that we are not capturing all the isotopes! We should think about what isotopes we should add to get a better fit. \n",
"\n",
"* First list the isotopes and abundances, \n",
"* Then we can update the abundances based on the lptresults\n",
"* Finally we can add another isotope, like Ta (hint: its Ta)"
"* Finally we can add another isotope, like Ta (hint: its Ta)\n",
"\n",
"Additionally, we can change the name of the `sammy_fit_dir` in case we want to compare new fit results to the original. "
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"id": "537592f3",
"metadata": {},
"outputs": [
Expand All @@ -350,7 +391,8 @@
"Initial Abundance: [0.01, 0.01]\n",
"Initial Thickness: 1.0\n",
"New Abundance: [0.01276, 0.0057509]\n",
"New Thickness: 0.11592\n"
"New Thickness: 0.11592\n",
"New fit directory: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238-ta181\n"
]
}
],
Expand All @@ -369,12 +411,18 @@
"\n",
"# check your work!\n",
"print(f\"New Abundance: {uranium.params['isotopes']['abundances']}\")\n",
"print(f\"New Thickness: {uranium.params['broadening']['thickness']}\")\n"
"print(f\"New Thickness: {uranium.params['broadening']['thickness']}\")\n",
"\n",
"# Update the `sammy_fit_dir` to a new directory name\n",
"uranium.params['directories']['sammy_fit_dir'] = uranium.params['directories']['sammy_fit_dir'] + \"-ta181\"\n",
"\n",
"# check your work!\n",
"print(f\"New fit directory: {uranium.params['directories']['sammy_fit_dir']}\")\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"id": "2ed528b0",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -409,7 +457,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 15,
"id": "c1531978",
"metadata": {},
"outputs": [],
Expand All @@ -428,7 +476,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 16,
"id": "072df3f1",
"metadata": {},
"outputs": [
Expand All @@ -437,16 +485,16 @@
"output_type": "stream",
"text": [
"total 20K\n",
"drwxr-xr-x 5 l280162 l280162 4.0K Jul 10 20:43 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 20:43 ..\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 20:43 Ta181\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 20:43 U235\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 20:43 U238\n"
"drwxr-xr-x 5 l280162 l280162 4.0K Jul 10 22:38 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 ..\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 22:38 Ta181\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 22:38 U235\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 22:38 U238\n"
]
}
],
"source": [
"!ls -lah .archive/endf"
"!ls -lah .archive/endf/"
]
},
{
Expand All @@ -461,7 +509,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 17,
"id": "3c6bcc36",
"metadata": {},
"outputs": [
Expand All @@ -470,10 +518,11 @@
"output_type": "stream",
"text": [
"Creating SAMMY parFile files for isotopes: ['U-235', 'U-238', 'Ta-181'] with abundances: [0.01276, 0.0057509, 0.01]\n",
"Writing output parFile: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238/params.par\n",
"Writing output parFile: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238-ta181/params.par\n",
"Creating SAMMY inpFile files for isotopes: ['U-235', 'U-238', 'Ta-181'] with abundances: [0.01276, 0.0057509, 0.01]\n",
"No config file given. Using default parameters.\n",
"Created compound input file: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238/input.inp\n"
"Created compound input file: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238-ta181/input.inp\n",
"Symlinking data file: /home/l280162/Programs/PLEIADES/examples/data/u235-u238.twenty into /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238-ta181\n"
]
}
],
Expand All @@ -482,6 +531,37 @@
"sammyUtils.configure_sammy_run(uranium,verbose_level=1)"
]
},
{
"cell_type": "markdown",
"id": "40847c94",
"metadata": {},
"source": [
"#### `ls` the directory to see if anything was updated. "
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "cec02279",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"total 20K\n",
"drwxr-xr-x 5 l280162 l280162 4.0K Jul 10 22:39 .\n",
"drwxr-xr-x 4 l280162 l280162 4.0K Jul 10 22:35 ..\n",
"drwxr-xr-x 5 l280162 l280162 4.0K Jul 10 22:38 endf\n",
"drwxr-xr-x 3 l280162 l280162 4.0K Jul 10 22:38 u235-u238\n",
"drwxr-xr-x 2 l280162 l280162 4.0K Jul 10 22:39 u235-u238-ta181\n"
]
}
],
"source": [
"!ls -lah .archive/"
]
},
{
"cell_type": "markdown",
"id": "4b20bb33",
Expand All @@ -496,17 +576,17 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 19,
"id": "882ae5d7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running SAMMY for /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238\n",
"Output file: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238/output.out\n",
"Running SAMMY for u235-u238...\n",
"Running SAMMY for /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238-ta181\n",
"Output file: /home/l280162/Programs/PLEIADES/examples/Notebooks/.archive/u235-u238-ta181/output.out\n",
"Running SAMMY for u235-u238-ta181...\n",
"SAMMY executed successfully.\n"
]
}
Expand All @@ -526,7 +606,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 20,
"id": "583f22bb",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -580,6 +660,14 @@
"print(json.dumps(uranium_fit._results['Iteration Results'][-1],indent=4))"
]
},
{
"cell_type": "markdown",
"id": "e81eee65",
"metadata": {},
"source": [
"#### <span style=\"color:red\">Bug:</span> Pleiades is only printing two isotopes. "
]
},
{
"cell_type": "markdown",
"id": "ddba4fd0",
Expand All @@ -590,7 +678,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 21,
"id": "697222b9",
"metadata": {},
"outputs": [
Expand Down
11 changes: 1 addition & 10 deletions pleiades/sammyRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ def single_run(fit_dir: str= "", input_file: str = "", par_file: str = "", data_
raise ValueError("Parameter file is required")
if not data_file:
raise ValueError("Data file is required")

# Create a symbolic link to the data file in the fit_dir
data_file_name = pathlib.Path(data_file).name

# Check if the symbolic link already exists
if os.path.islink(pathlib.Path(fit_dir) / data_file_name):
os.unlink(pathlib.Path(fit_dir) / data_file_name) # unlink old symlink

os.symlink(data_file, pathlib.Path(fit_dir) / data_file_name) # create new symlink

# Check if files exist
full_path_to_input_file = pathlib.Path(fit_dir) / input_file
Expand Down Expand Up @@ -62,7 +53,7 @@ def single_run(fit_dir: str= "", input_file: str = "", par_file: str = "", data_
sammy <<EOF
{input_file}
{par_file}
{data_file_name}
{data_file}
EOF""")

Expand Down
Loading

0 comments on commit 528bdc9

Please sign in to comment.