Example #1
0
    def find_stable_Smat_poles(self):
        cal = rk.get_asym_calc(cu.hartrees, [0, 0])
        csmat = rw.get_Smat_fun(1.0, 2.0, 2.0, cal, 1.0)
        dsmat = csmat.discretise(1., 8., 100)

        rk.get_tool(rk.mcsmatfit, dsmat, archive_root=TEST_ROOT, silent=True)
        rk.get_tool(rk.mcsmatfit, dsmat, archive_root=TEST_ROOT, silent=True)

        dsmat.asymcalc.units = cu.rydbergs
        self.assertRaises(Exception,
                          rk.get_tool,
                          rk.mcsmatfit,
                          dsmat,
                          archive_root=TEST_ROOT,
                          silent=True)
Example #2
0
    def runTest(self):
        # Test that the three modes (mpmath, python with and without sympy
        # nroots) all return different results.
        dsmat = self.get_dsmat()
        rk.use_python_types()
        mcsmatfit = rk.get_tool(rk.mcsmatfit, dsmat, silent=True)
        roots1 = self.get_roots(mcsmatfit)
        mcsmatfit = rk.get_tool(
            rk.mcsmatfit,
            dsmat,
            silent=True,
            param_file_path="test_mcsmatfit_calc_modes.yaml")
        roots2 = self.get_roots(mcsmatfit)
        rk.use_mpmath_types(dps=100)
        dsmat = self.get_dsmat()
        mcsmatfit = rk.get_tool(rk.mcsmatfit, dsmat, silent=True)
        roots3 = self.get_roots(mcsmatfit)

        self.assertNotEqual(str(roots1), str(roots2))
        self.assertNotEqual(str(roots1), str(roots3))
        self.assertNotEqual(str(roots2), str(roots3))
    def find_stable_Smat_poles(self):
        cal = rk.get_asym_calc(cu.hartrees, [0,0])
        csmat = rw.get_Smat_fun(1.0,2.0,2.0,cal,1.0)
        dsmat = csmat.discretise(1.,8.,100)

        mcsmatfit = rk.get_tool(rk.mcsmatfit, dsmat, archive_root=TEST_ROOT,
                               silent=True)
        cfins = mcsmatfit.get_elastic_Fins(range(2,4,2))
        mcsmatfit.find_stable_Smat_poles(cfins)

        # Import again with same config and check no exception
        rk.get_tool(rk.mcsmatfit, dsmat, archive_root=TEST_ROOT, silent=True)

        testPath = fileDir+os.sep+"test_mcsmatfit_data1"+os.sep+"default.yaml"
        self.assertRaises(Exception, rk.get_tool, rk.mcsmatfit, dsmat,
                          archive_root=TEST_ROOT, param_file_path=testPath,
                          silent=True)

        testPath = fileDir+os.sep+"test_mcsmatfit_data2"+os.sep+"default.yaml"
        self.assertRaises(Exception, rk.get_tool, rk.mcsmatfit, dsmat,
                          archive_root=TEST_ROOT, param_file_path=testPath,
                          silent=True)
    def find_stable_Smat_poles(self):
        cal = rk.get_asym_calc(cu.hartrees, [0,0])
        csmat = rw.get_Smat_fun(1.0,2.0,2.0,cal,1.0)
        dsmat = csmat.discretise(1.,8.,100)
        mcsmatfit = rk.get_tool(rk.mcsmatfit, dsmat, archive_root=TEST_ROOT,
                                silent=True)

        mcsmatfit.get_elastic_Smat(6)

        cfins = mcsmatfit.get_elastic_Fins(range(2,10,2))
        mcsmatfit.find_stable_Smat_poles(cfins)
        self.assertFalse(mcsmatfit.all_coeffs_loaded)
        self.assertFalse(mcsmatfit.all_roots_loaded)

        cfins = mcsmatfit.get_elastic_Fins(range(2,10,2))
        self.assertTrue(mcsmatfit.all_coeffs_loaded)
        # False because we haven't called find_stable_Smat_poles yet
        self.assertFalse(mcsmatfit.all_roots_loaded)

        roots = mcsmatfit.find_Fin_roots(cfins)
        mcsmatfit.find_stable_Smat_poles(roots)
        self.assertTrue(mcsmatfit.all_roots_loaded)
Example #5
0
                                       desc_str)
else:
    # System is a molecule
    # Read in the K matrix data
    # Get a calculator with units and channel angular momentum
    calc = rk.get_asym_calc(rk.rydbergs, ang_mom)
    kmatdict,_ = rmol.read_Kmats(input_data_file)
    # Initialise the data into the required container
    dmat = rk.get_dmat_from_discrete(rk.Kmat, kmatdict, calc, desc_str)

# Slice the data set
if sl is not None:
    dmat = dmat[sl]

if sys.argv[2] in ("poles", "plotSmat", "plotXS"):
    sfittool = rk.get_tool(rk.mcsmatfit, dmat, archive_path, param_path)
    if sys.argv[2] == "poles":
        if not Npts:
            Npts = 40
        # Perform the calculation of the poles and the quality indicators
        cfins = sfittool.get_elastic_Fins(range(2,Npts+2,2))
        sfittool.find_stable_Smat_poles(cfins)
    elif sys.argv[2] in ("plotSmat", "plotXS"):
        if not Npts:
            Npts = 20
        # Perform the calculation of the poles and the quality indicators
        csmat = sfittool.get_elastic_Smat(Npts)
        if sys.argv[2] == "plotSmat":
            sfittool.plot_Smat_fit(csmat, num_plot_points=num_plot_points)
        elif sys.argv[1] == "uracil":
            sfittool.plot_XS_fit(csmat, num_plot_points=num_plot_points, logy=True)
Example #6
0
if len(sys.argv) > 1 and sys.argv[1] == "mpmath":
    cu.use_mpmath_types()
    print "mpmath"
else:
    print "python"

TEST_ROOT = "chart"
if os.path.isdir(TEST_ROOT):
    shutil.rmtree(TEST_ROOT)

cal = cu.AsymCalc(cu.hartrees, [0, 0])
csmat = rw.get_Smat_fun(1.0, 2.0, 2.0, cal, 1.0)

print "Plot all data as S-matrix, direct from continuous data. No archive."
chart = rk.get_tool(rk.chart, csmat)
chart.plot_Smatrix()

print "Use discretised data."
dsmat = csmat.discretise(1., 8., 100)
chart = rk.get_tool(rk.chart, dsmat)

print "Plot all data as S-matrix. No archive. Row."
chart.plot_Smatrix(i=0)

print "Archive created"
chart = rk.get_tool(rk.chart, dsmat, TEST_ROOT)

print "Plot all data as S-matrix. Column."
chart.plot_Smatrix(j=1)
Example #7
0
    csmat = rw.get_Smat_fun(1.0,2.0,2.0,calc,1.0)
    dmat = rk.get_dmat_from_continuous(rk.Smat, csmat, calc, 1., 8., 200,
                                       "radwell")
else:
    # This data is only available in the distribution package.
    if sys.argv[2] == "pyrazine":
        input_data_file = "../../../../examples/kmatrix_input_pyrazine.txt"
        calc = rk.get_asym_calc(rk.rydbergs, [3,5,5])
    else:
        input_data_file = "../../../../examples/kmatrix_input_pbq.txt"
        calc = rk.get_asym_calc(rk.rydbergs, [1,3,3])
    kmatdict,_ = rmol.read_Kmats(input_data_file)
    dmat = rk.get_dmat_from_discrete(rk.Kmat, kmatdict, calc, "PBQ")


sfittool = rk.get_tool(rk.mcsmatfit, dmat, TEST_ROOT)

csmat = sfittool.get_elastic_Smat(10)

print "S matrix"
print "All elements. Default number of points"
sfittool.plot_Smat_fit(csmat)
print "All elements"
sfittool.plot_Smat_fit(csmat, 100)
print "Row eVs"
sfittool.plot_Smat_fit(csmat, 100, units=rk.eVs, i=1)
print "Column hartrees imaginary"
sfittool.plot_Smat_fit(csmat, 100, units=rk.hartrees, j=0, imag=True)
print "Element"
sfittool.plot_Smat_fit(csmat, 100, i=1, j=0)
print "Element logx"
Example #8
0
import os
import sys
import shutil
fileDir = os.path.dirname(os.path.realpath(__file__))
rkPath = fileDir + '/../../../..'
sys.path.insert(0, rkPath)

import reskit as rk
import channelutil as cu
import twochanradialwell as tcrw

TEST_ROOT = "chart-Smat-fin-fit"
if os.path.isdir(TEST_ROOT):
    shutil.rmtree(TEST_ROOT)

calc = rk.get_asym_calc(rk.hartrees, [0, 0])
csmat = tcrw.get_Smat_fun(1.0, 2.0, 2.0, calc, 1.0)
dmat = rk.get_dmat_from_continuous(rk.Smat, csmat, calc, 1., 8., 1200,
                                   "radwell")

sfittool = rk.get_tool(rk.mcsmatfit, dmat, TEST_ROOT)
cfin = sfittool.get_elastic_Fin(10)

chart = rk.get_tool(rk.chart, cfin, TEST_ROOT)
chart.plot_raw()
Example #9
0
import os
import sys
fileDir = os.path.dirname(os.path.realpath(__file__))
rkPath = fileDir + '/../../../..'
sys.path.insert(0, rkPath)

import reskit as rk

POLE_DATA_FOLDER = "create_formatted_QI_tables"

smatfit = rk.get_tool(rk.mcsmatfit, None)

typs = ["latex", "html", "raw"]
quants = ["E", "k"]
truns = [True, False]
sig_digits = [None, 4, 10]


def _create_table(typ, quant, trun, sig_digit):
    smatfit.create_formatted_QI_tables(typ + quant,
                                       trun,
                                       sig_digit,
                                       spec_path=POLE_DATA_FOLDER)


for typ in typs:
    for quant in quants:
        for trun in truns:
            for sig_digit in sig_digits:
                _create_table(typ, quant, trun, sig_digit)