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)
def runTest(self): asymcalc = chanutil.AsymCalc(chanutil.hartrees, thresholds=[0.,2.]) fun = radwell.get_Smat_fun(1., 2., 2., asymcalc, 1.) expect_mat = radwell.nw.matrix([[1., 0.],[0., -13.56891277]]) got_mat = fun(0.) self.assertTrue(radwell.nw.np.allclose(got_mat,expect_mat)) expect_mat = radwell.nw.matrix(\ [[-0.92934972-0.36920061j, 3.95429415+5.82581759j], [3.95429415+5.82581759j, -22.30580611-24.7882964j]]) got_mat = fun(1.8) self.assertTrue(radwell.nw.np.allclose(got_mat,expect_mat)) expect_mat = radwell.nw.matrix(\ [[0.17030364+0.94186257j, -0.26879527-0.10789196j], [-0.26879527-0.10789196j, -0.77423472+0.56273353j]]) got_mat = fun(3.0) self.assertTrue(radwell.nw.np.allclose(got_mat,expect_mat))
def runTest(self): asymcalc = chanutil.AsymCalc(chanutil.hartrees, [0, 0]) fun = radwell.get_Smat_fun(1., 2., 2., asymcalc, 1.) expect_mat = radwell.nw.matrix([[1., 0.], [0., 1.]]) got_mat = fun(0.) self.assertTrue(radwell.nw.np.allclose(got_mat, expect_mat)) expect_mat = radwell.nw.matrix(\ [[-0.31507906+0.89937359j, -0.28602697-0.10020431j], [-0.28602697-0.10020431j, -0.31507906+0.89937359j]]) got_mat = fun(1.8) self.assertTrue(radwell.nw.np.allclose(got_mat, expect_mat)) expect_mat = radwell.nw.matrix(\ [[0.1665721+0.95554805j, -0.23965872+0.04177755j], [-0.23965872+0.04177755j, 0.1665721+0.95554805j]]) got_mat = fun(3.0) self.assertTrue(radwell.nw.np.allclose(got_mat, expect_mat))
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)
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)
input_data_file = "kmatrix_input_pbq.txt" ang_mom = [1,3,3] sl = slice(0,624) num_plot_points = 312 param_path = "test_configuration_2.yaml" else: raise Exception(exceptStr) rk.use_mpmath_types(dps=100) if input_data_file is None: # System is a radial well # Get a calculator with units and channel angular momentum calc = rk.get_asym_calc(rk.hartrees, ang_mom) # Get a function pointer for the S matrix csmat = tcrw.get_Smat_fun(1.0, 2.0, 2.0, calc, 1.0) # Initialise the data into the required container dmat = rk.get_dmat_from_continuous(rk.Smat, csmat, calc, 1., 8., 1200, 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]
rk.safe_mode = False import channelutil as cu import twochanradialwell as rw 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)
def get_dsmat(self): cal = rk.get_asym_calc(cu.hartrees, [0, 0]) csmat = rw.get_Smat_fun(1.0, 2.0, 2.0, cal, 1.0) return csmat.discretise(1., 8., 100)