Skip to content

Commit 4dbf965

Browse files
committed
feat: integrated PleiadesConfig fit configuration into INP file generation
1 parent 4843c70 commit 4dbf965

File tree

3 files changed

+286
-224
lines changed

3 files changed

+286
-224
lines changed

docs/guides/input_preparation.rst

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -69,45 +69,51 @@ INP File Generation
6969
The INP file controls SAMMY execution parameters. PLEIADES generates
7070
INP files through :class:`~pleiades.sammy.io.inp_manager.InpManager`.
7171

72-
Material Properties
73-
^^^^^^^^^^^^^^^^^^^
72+
Dataset Metadata
73+
^^^^^^^^^^^^^^^^
7474

75-
Define material properties as a dictionary:
75+
Define typed dataset metadata and fit configuration:
7676

7777
.. code-block:: python
7878
79-
material_props = {
80-
'element': 'Au', # Element symbol
81-
'mass_number': 197, # Isotope mass number
82-
'density_g_cm3': 19.32, # Material density (g/cm³)
83-
'thickness_mm': 0.025, # Sample thickness (mm)
84-
'atomic_mass_amu': 196.966569, # Atomic mass (amu)
85-
'abundance': 1.0, # Isotopic abundance (0-1)
86-
'min_energy': 1.0, # Minimum energy (eV)
87-
'max_energy_eV': 200.0, # Maximum energy (eV)
88-
'temperature_K': 293.6, # Sample temperature (K)
89-
}
79+
from pleiades.sammy.fitting.config import FitConfig
80+
from pleiades.sammy.io.inp_manager import InpDatasetMetadata
81+
82+
fit_config = FitConfig()
83+
fit_config.physics_params.broadening_parameters.crfn = 8.0
84+
85+
dataset_metadata = InpDatasetMetadata(
86+
element="Au",
87+
mass_number=197,
88+
density_g_cm3=19.32,
89+
thickness_mm=0.025,
90+
atomic_mass_amu=196.966569,
91+
min_energy_eV=1.0,
92+
max_energy_eV=200.0,
93+
temperature_K=293.6,
94+
)
9095
9196
Creating the INP File
9297
^^^^^^^^^^^^^^^^^^^^^
9398

9499
.. code-block:: python
95100
96101
from pathlib import Path
97-
from pleiades.sammy.io.inp_manager import InpManager
98-
99-
# Material properties
100-
material_props = {
101-
'element': 'Au',
102-
'mass_number': 197,
103-
'density_g_cm3': 19.32,
104-
'thickness_mm': 0.025,
105-
'atomic_mass_amu': 196.966569,
106-
'abundance': 1.0,
107-
'min_energy': 1.0,
108-
'max_energy_eV': 200.0,
109-
'temperature_K': 293.6,
110-
}
102+
from pleiades.sammy.fitting.config import FitConfig
103+
from pleiades.sammy.io.inp_manager import InpDatasetMetadata, InpManager
104+
105+
fit_config = FitConfig()
106+
fit_config.physics_params.broadening_parameters.crfn = 8.0
107+
dataset_metadata = InpDatasetMetadata(
108+
element="Au",
109+
mass_number=197,
110+
density_g_cm3=19.32,
111+
thickness_mm=0.025,
112+
atomic_mass_amu=196.966569,
113+
min_energy_eV=1.0,
114+
max_energy_eV=200.0,
115+
temperature_K=293.6,
116+
)
111117
112118
# Resolution function file (facility-specific)
113119
resolution_file = Path("/path/to/resolution_function.dat")
@@ -116,8 +122,9 @@ Creating the INP File
116122
inp_file = Path("./working/analysis.inp")
117123
InpManager.create_multi_isotope_inp(
118124
inp_file,
125+
fit_config=fit_config,
119126
title="Au-197 neutron transmission analysis",
120-
material_properties=material_props,
127+
dataset_metadata=dataset_metadata,
121128
resolution_file_path=resolution_file,
122129
)
123130
@@ -261,7 +268,8 @@ Putting it all together:
261268
.. code-block:: python
262269
263270
from pathlib import Path
264-
from pleiades.sammy.io.inp_manager import InpManager
271+
from pleiades.sammy.fitting.config import FitConfig
272+
from pleiades.sammy.io.inp_manager import InpDatasetMetadata, InpManager
265273
from pleiades.sammy.io.json_manager import JsonManager
266274
from pleiades.sammy.io.data_manager import convert_csv_to_sammy_twenty
267275
from pleiades.sammy.interface import SammyFilesMultiMode
@@ -289,24 +297,27 @@ Putting it all together:
289297
working_dir=str(working_dir),
290298
)
291299
292-
# 3. Create INP file
293-
material_props = {
294-
'element': 'Au',
295-
'mass_number': 197,
296-
'density_g_cm3': 19.32,
297-
'thickness_mm': 0.025,
298-
'atomic_mass_amu': 196.966569,
299-
'abundance': 1.0,
300-
'min_energy': 1.0,
301-
'max_energy_eV': 200.0,
302-
'temperature_K': 293.6,
303-
}
300+
# 3. Create INP file from FitConfig + typed metadata
301+
fit_config = FitConfig()
302+
fit_config.physics_params.broadening_parameters.crfn = 8.0
303+
304+
dataset_metadata = InpDatasetMetadata(
305+
element="Au",
306+
mass_number=197,
307+
density_g_cm3=19.32,
308+
thickness_mm=0.025,
309+
atomic_mass_amu=196.966569,
310+
min_energy_eV=1.0,
311+
max_energy_eV=200.0,
312+
temperature_K=293.6,
313+
)
304314
305315
inp_file = working_dir / "au_fitting.inp"
306316
InpManager.create_multi_isotope_inp(
307317
inp_file,
318+
fit_config=fit_config,
308319
title="Au-197 analysis",
309-
material_properties=material_props,
320+
dataset_metadata=dataset_metadata,
310321
resolution_file_path=Path("/path/to/resolution.dat"),
311322
)
312323

0 commit comments

Comments
 (0)