Ejemplo n.º 1
0
def test_qm_spinsystem_peaklist():
    # GIVEN v and J inputs
    v, J = rioux()
    # WHEN qm_spinsystem is called with v and J and all possible cache/sparse
    spectrum_TT = qm_spinsystem(v, J, cache=True, sparse=True, normalize=True)
    spectrum_FT = qm_spinsystem(v, J, cache=False, sparse=True, normalize=True)
    spectrum_TF = qm_spinsystem(v, J, cache=True, sparse=False, normalize=True)
    spectrum_FF = qm_spinsystem(v,
                                J,
                                cache=False,
                                sparse=False,
                                normalize=True)
    # THEN they all match the expected result
    for s in [spectrum_TT, spectrum_FT, spectrum_TF, spectrum_FF]:
        assert np.allclose(s, SPECTRUM_RIOUX)
Ejemplo n.º 2
0
def abx_wrapper(va=110.0, vb=90.0, vx=200.0, Jax=5.0, Jbx=10.0, Jab=13.0):
    # x = np.linspace(0, 235, 8000)
    freqs = [va, vb, vx]
    Js = np.array(
        [[0.0, Jab, Jax],
         [Jab, 0.0, Jbx],
         [Jax, Jbx, 0]])
    peaklist = qm_spinsystem(freqs, Js)
    # y = add_lorentzians(x, peaklist, 0.5)
    return peaklist
Ejemplo n.º 3
0
    def peaklist(self):
        """Return a list of (frequency, intensity) signals.

        Returns
        -------
        [(float, float)...]
            Array of (frequency, intensity) signals.
        """
        if self._second_order:
            return qm_spinsystem(self._v, self._J)
        else:
            return first_order_spin_system(self._v, self._J)
Ejemplo n.º 4
0
def interactive_aaxx(va=110.0, vx=90.0,
                     Jaa=15.0, Jxx=15.0, Jax=7.0, Jax_prime=7.0):
    datapoints = max(abs(int(va - vx)) * 100, 800)
    # x = np.linspace(min_, max_, 8000)
    freqs = [va, va, vx, vx]
    Js = np.array(
        [[0.0, Jaa, Jax, Jax_prime],
         [Jaa, 0.0, Jax_prime, Jax],
         [Jax, Jax_prime, 0, Jxx],
         [Jax_prime, Jax, Jxx, 0]])
    peaklist = qm_spinsystem(freqs, Js)
    xy = lineshape_from_peaklist(peaklist, points=datapoints)
    plot = hv.Curve(zip(*xy))
    return plot.options(axiswise=True, invert_xaxis=True,
                        xlabel='𝜈',
                        height=300, responsive=True
                        ).redim(y=hv.Dimension('intensity', range=(-0.4, 1.2)))
Ejemplo n.º 5
0
def AABB(Vab, Jaa, Jbb, Jab, Jab_prime, Vcentr, normalize=True, **kwargs):
    """
    A wrapper for a second-order AA'BB' calculation, but using the
    same arguments as WINDNMR.

    Parameters
    ---------
    Vab : float
        the difference in frequency (Hz) between Ha and Hb in the absence of
        coupling. A positive number indicates vb > va.
    Jaa, Jbb, Jab, Jab_prime : float
        Jaa is the JAA' coupling constant;
        Jxx the JXX';
        Jax the JAX; and
        JAX_prime the JAX'.
    Vcentr : float
        the frequency for the center of the signal.
    normalize: bool
        whether the signal intensity should be normalized.

    Returns
    -------
    [(float, float)...]
        a list of (frequency, intensity) tuples.
    """
    from nmrsim.qm import qm_spinsystem
    va = Vcentr - Vab / 2
    vb = Vcentr + Vab / 2
    freqlist = [va, va, vb, vb]
    J = np.zeros((4, 4))
    J[0, 1] = Jaa
    J[0, 2] = Jab
    J[0, 3] = Jab_prime
    J[1, 2] = Jab_prime
    J[1, 3] = Jab
    J[2, 3] = Jbb
    J = J + J.T

    result = qm_spinsystem(freqlist,
                           J,
                           normalize=normalize,
                           sparse=False,
                           **kwargs)
    return result
Ejemplo n.º 6
0
 def update_qm(self, *args):
     peaklist = qm_spinsystem(*args)
     return self.peaklist_to_xy(peaklist)