From fd20542c5773e78f8dc28dbd26b30570bcf304a9 Mon Sep 17 00:00:00 2001 From: jupfi Date: Tue, 11 Jun 2024 17:42:01 +0200 Subject: [PATCH] Added spin factor scaling, fixed dostring for atoms per volume. --- src/nqr_blochsimulator/classes/sample.py | 4 ++-- src/nqr_blochsimulator/classes/simulation.py | 4 ++++ tests/simulation.py | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/nqr_blochsimulator/classes/sample.py b/src/nqr_blochsimulator/classes/sample.py index fce067f..066eddd 100644 --- a/src/nqr_blochsimulator/classes/sample.py +++ b/src/nqr_blochsimulator/classes/sample.py @@ -38,7 +38,7 @@ class Sample: name : str The name of the sample. atoms : float - The number of atoms in the sample. + The number of atoms per unit volume of the sample (1/m^3). resonant_frequency : float The resonant frequency of the sample in MHz. gamma : float @@ -94,7 +94,7 @@ class Sample: def calculate_atoms(self): """ - Calculate the number of atoms in the sample per volume unit. This only works if the sample volume and atom density are provided. + Calculate the number of atoms in the sample per volume unit (1/m^3). This only works if the sample volume and atom density are provided. Also the sample should be cylindrical. If atom density and sample volume are provided, use these to calculate the number of atoms. diff --git a/src/nqr_blochsimulator/classes/simulation.py b/src/nqr_blochsimulator/classes/simulation.py index 3ea0f26..0cc33ab 100644 --- a/src/nqr_blochsimulator/classes/simulation.py +++ b/src/nqr_blochsimulator/classes/simulation.py @@ -278,6 +278,10 @@ class Simulation: * self.number_turns / self.length_coil ) + + # Spin Factor Scaling + B1 = B1 * self.sample.spin_factor + return B1 def calc_xdis(self) -> np.array: diff --git a/tests/simulation.py b/tests/simulation.py index fe56bc7..55f4d46 100644 --- a/tests/simulation.py +++ b/tests/simulation.py @@ -19,7 +19,7 @@ class TestSimulation(unittest.TestCase): resonant_frequency=83.56e6, # Hz gamma=43.42, # MHz/T nuclear_spin= "9/2", - spin_factor=1.94 + spin_factor=1.94, powder_factor=0.75, filling_factor=0.7, T1=83.5, # µs @@ -76,8 +76,8 @@ class TestSimulation(unittest.TestCase): def test_spin_factor_calculation(self): - spin = self.sample.nuclear_spin - transition = 1 + spin = 2.5 + transition = 2 spin_factor = self.sample.calculate_spin_transition_factor(spin, transition) logger.info("Spin factor: " + str(spin_factor))