Made nuclear spin a selection setting.

This commit is contained in:
jupfi 2024-06-04 16:26:37 +02:00
parent 6a853ed0bf
commit 2bfea9c3aa
2 changed files with 18 additions and 4 deletions

View file

@ -89,6 +89,7 @@ class SimulatorController(SpectrometerController):
sample_diameter = None
name = model.settings.sample_name
n_atoms = model.settings.n_atoms
density = model.settings.density
molar_mass = model.settings.molar_mass
resonant_frequency = model.settings.resonant_frequency
@ -103,6 +104,7 @@ class SimulatorController(SpectrometerController):
sample = Sample(
name=name,
atoms=n_atoms,
density=density,
molar_mass=molar_mass,
resonant_frequency=resonant_frequency,

View file

@ -6,6 +6,7 @@ from quackseq.spectrometer.spectrometer_settings import (
IntSetting,
FloatSetting,
StringSetting,
SelectionSetting,
)
logger = logging.getLogger(__name__)
@ -37,6 +38,7 @@ class SimulatorModel(SpectrometerModel):
# Sample settings, this will be done in a separate module later on
SAMPLE_NAME = "Name"
NUMBER_ATOMS = "Number of atoms"
DENSITY = "Density (g/cm^3)"
MOLAR_MASS = "Molar mass (g/mol)"
RESONANT_FREQUENCY = "Resonant freq. (MHz)"
@ -232,6 +234,15 @@ class SimulatorModel(SpectrometerModel):
)
self.add_setting("sample_name", sample_name_setting)
sample_n_atoms_setting = IntSetting(
self.NUMBER_ATOMS,
self.SAMPLE,
0,
"The number of atoms in the sample.",
min_value=0,
)
self.add_setting("n_atoms", sample_n_atoms_setting)
density_setting = FloatSetting(
self.DENSITY,
self.SAMPLE,
@ -270,12 +281,13 @@ class SimulatorModel(SpectrometerModel):
)
self.add_setting("gamma", gamma_setting)
nuclear_spin_setting = FloatSetting(
spin_options = ["3/2", "5/2", "7/2", "9/2"]
nuclear_spin_setting = SelectionSetting(
self.NUCLEAR_SPIN,
self.SAMPLE,
9 / 2,
"The nuclear spin of the samples nuclei.",
min_value=0,
spin_options,
default="9/2",
description="The nuclear spin of the samples nuclei.",
)
self.add_setting("nuclear_spin", nuclear_spin_setting)