From 2bfea9c3aa6aecd686187e9b313c776932cba6aa Mon Sep 17 00:00:00 2001 From: jupfi Date: Tue, 4 Jun 2024 16:26:37 +0200 Subject: [PATCH] Made nuclear spin a selection setting. --- .../simulator_controller.py | 2 ++ src/quackseq_simulator/simulator_model.py | 20 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/quackseq_simulator/simulator_controller.py b/src/quackseq_simulator/simulator_controller.py index 3c1bc00..3bf3110 100644 --- a/src/quackseq_simulator/simulator_controller.py +++ b/src/quackseq_simulator/simulator_controller.py @@ -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, diff --git a/src/quackseq_simulator/simulator_model.py b/src/quackseq_simulator/simulator_model.py index 6b4e1c0..daf6c73 100644 --- a/src/quackseq_simulator/simulator_model.py +++ b/src/quackseq_simulator/simulator_model.py @@ -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 sample’s nuclei.", - min_value=0, + spin_options, + default="9/2", + description="The nuclear spin of the sample’s nuclei.", ) self.add_setting("nuclear_spin", nuclear_spin_setting)