def test_get_C_K_ij_lag3(): """test transition counts at lag time 3""" trajs = [{ 'm': np.array([0, 1, 2, 0], dtype=np.intc), 't': np.zeros(shape=(4, ), dtype=np.intc) }] td = TRAMData(trajs) C_K_ij = np.array([[[1, 0, 0], [0, 0, 0], [0, 0, 0]]], dtype=np.intc) assert_true(np.all(C_K_ij == td.get_C_K_ij(3)))
def test_Mx_Tx_nMTstates(): seq = np.array(range(20), dtype=np.intc) trajs = [{'m': seq[:10], 't': seq[:10]}, {'m': seq[10:], 't': seq[10:]}] td = TRAMData(trajs) assert_true(np.all((seq - td.T_x) == 0)) assert_true(np.all((seq - td.M_x) == 0)) assert_true(td.n_markov_states == 20) assert_true(td.n_therm_states == 20)
def test_N_K_i(): trajs = [] for K in xrange(3): trajs.append({ 'm': np.array(range(4), dtype=np.intc), 't': np.ones(shape=(4, ), dtype=np.intc) * K }) td = TRAMData(trajs) assert_true(np.all(td.N_K_i == 1)) assert_true(np.all(td.N_K == 4)) assert_true(td.N_K.sum() == 12)
def test_xtram_api(self): """testing the xTRAM API""" tramdata = TRAMData(self.inp, verbose=True) xtram_obj = xtram(tramdata, lag=1, maxiter=1, ftol=1.0E-13, verbose=True) xtram_obj = xtram(tramdata, lag=1, maxiter=10000, ftol=1.0E-13, verbose=True) maxerr = 1.0E-1 assert_allclose(xtram_obj.f_K, self.f_K, atol=maxerr) assert_allclose(xtram_obj.f_i, self.f_i, atol=maxerr) assert_allclose(xtram_obj.pi_i, self.pi_i, atol=maxerr) assert_allclose(xtram_obj.f_K_i, self.f_K_i, atol=maxerr) assert_allclose(xtram_obj.pi_K_i, self.pi_K_i, atol=maxerr)
def test_dtram_api(self): """testing the dTRAM API""" tramdata = TRAMData(self.inp, b_K_i=self.b_K_i, verbose=True) dtram_obj = dtram(tramdata, lag=1, maxiter=1, ftol=1.0E-14, verbose=True) dtram_obj = dtram(tramdata, lag=1, maxiter=100000, ftol=1.0E-14, verbose=True) maxerr = 1.0E-1 assert_allclose(dtram_obj.f_K, self.f_K, atol=maxerr) assert_allclose(dtram_obj.f_i, self.f_i, atol=maxerr) assert_allclose(dtram_obj.pi_i, self.pi_i, atol=maxerr) assert_allclose(dtram_obj.f_K_i, self.f_K_i, atol=maxerr) assert_allclose(dtram_obj.pi_K_i, self.pi_K_i, atol=maxerr) assert_allclose(dtram_obj.estimate_transition_matrices(), self.tmat, atol=maxerr)
def test_get_C_K_ij_lag3(): """test transition counts at lag time 3""" trajs = [{'m': np.array([0, 1, 2, 0], dtype=np.intc), 't': np.zeros(shape=(4,), dtype=np.intc)}] td = TRAMData(trajs) C_K_ij = np.array([[[1, 0, 0], [0, 0, 0], [0, 0, 0]]], dtype=np.intc) assert_true(np.all(C_K_ij == td.get_C_K_ij(3)))
plt.show() #%% T = sim_data.get_reweighted_TransMtx() p = sim_data.get_reweighted_distribution(T) plt.plot(gridpoints, p) #%% ################################ # OLD code continues... ################################ dtramdata = TRAMData( sim_data.trajs, b_K_i=sim_data.gen_harmonic_bias_mtx(gridpoints=sim_data.gridpoints)) try: dtram_obj = dtram(dtramdata, lag=opts.lag_time, maxiter=1, ftol=opts.f_toler_dtram, verbose=False) except pytram.ExpressionError: raise pytram.ExpressionError, "Input was faulty, ending..." except pytram.NotConvergedWarning: pass #%%
############################################################################ # # import the data # ############################################################################ print "#\n################################## IMPORTING DATA ##################################\n#" reader = Reader( args.files, b_K_i_file=args.b_K_i_file, maxlength=args.maxlength, skiprows=args.skiprows, verbose=True ) tramdata = TRAMData( reader.trajs, b_K_i=reader.b_K_i ) try: dtram_obj = DTRAM( tramdata.get_C_K_ij( args.lag ), tramdata.b_K_i ) except ExpressionError, e: print "#\n### ERROR\n#" print "# Your input was faulty!" print "# The < %s > object is malformed: %s" % ( e.expression, e.msg ) print "#\n### ABORTING\n\n" exit( 1 ) print "#\n### SYSTEM INFORMATION\n#" print "# %25s %24d" % ( "[markov states]", tramdata.n_markov_states ) print "# %25s %24d" % ( "[thermodynamic states]", tramdata.n_therm_states ) ############################################################################
############################################################################ # # import the data # ############################################################################ print "#\n################################## IMPORTING DATA ##################################\n#" reader = Reader( args.files, kT_file=args.kT_file, maxlength=args.maxlength, skiprows=args.skiprows, verbose=True ) tramdata = TRAMData( reader.trajs, kT_K=reader.kT_K, kT_target = args.kT_target) try: xtram_obj = XTRAM( tramdata.get_C_K_ij( args.lag ), tramdata.u_I_x, tramdata.T_x, tramdata.M_x, tramdata.N_K_i, tramdata.N_K, target = tramdata.kT_target, verbose = args.verbose ) except ExpressionError, e: print "#\n### ERROR\n#" print "# Your input was faulty!" print "# The < %s > object is malformed: %s" % ( e.expression, e.msg ) print "#\n### ABORTING\n\n" exit( 1 ) print "#\n### SYSTEM INFORMATION\n#" print "# %25s %24d" % ( "[markov states]", tramdata.n_markov_states ) print "# %25s %24d" % ( "[thermodynamic states]", tramdata.n_therm_states ) ############################################################################
print "# %25s %24d" % ("[--lag]", args.lag) print "# %25s %24d" % ("[--maxiter]", args.maxiter) print "# %25s %24.5e" % ("[--ftol]", args.ftol) ############################################################################ # # import the data # ############################################################################ print "#\n################################## IMPORTING DATA ##################################\n#" reader = Reader(args.files, b_K_i_file=args.b_K_i_file, maxlength=args.maxlength, skiprows=args.skiprows, verbose=True) tramdata = TRAMData(reader.trajs, b_K_i=reader.b_K_i) try: dtram_obj = DTRAM(tramdata.get_C_K_ij(args.lag), tramdata.b_K_i) except ExpressionError, e: print "#\n### ERROR\n#" print "# Your input was faulty!" print "# The < %s > object is malformed: %s" % (e.expression, e.msg) print "#\n### ABORTING\n\n" exit(1) print "#\n### SYSTEM INFORMATION\n#" print "# %25s %24d" % ("[markov states]", tramdata.n_markov_states) print "# %25s %24d" % ("[thermodynamic states]", tramdata.n_therm_states) ############################################################################ # # run the self-consistent-iteration
############################################################################ # # import the data # ############################################################################ print( "#\n################################## IMPORTING DATA ##################################\n#" ) reader = Reader(args.files, kT_file=args.kT_file, maxlength=args.maxlength, skiprows=args.skiprows, verbose=True) tramdata = TRAMData(reader.trajs, kT_K=reader.kT_K, kT_target=args.kT_target) try: xtram_obj = XTRAM(tramdata.get_C_K_ij(args.lag), tramdata.u_I_x, tramdata.T_x, tramdata.M_x, tramdata.N_K_i, target=tramdata.kT_target) except ExpressionError as e: print("#\n### ERROR\n#") print("# Your input was faulty!") print("# The < %s > object is malformed: %s" % (e.expression, e.msg)) print("#\n### ABORTING\n\n") exit(1) print("#\n### SYSTEM INFORMATION\n#")
############################################################################ # # import the data # ############################################################################ print "#\n################################## IMPORTING DATA ##################################\n#" reader = Reader( args.files, kT_file=args.kT_file, maxlength=args.maxlength, skiprows=args.skiprows, verbose=True ) tramdata = TRAMData( reader.trajs, kT_K=reader.kT_K, kT_target = args.kT_target) try: xtram_obj = XTRAM( tramdata.get_C_K_ij( args.lag ), tramdata.u_I_x, tramdata.T_x, tramdata.M_x, tramdata.N_K_i, target = tramdata.kT_target ) except ExpressionError, e: print "#\n### ERROR\n#" print "# Your input was faulty!" print "# The < %s > object is malformed: %s" % ( e.expression, e.msg ) print "#\n### ABORTING\n\n" exit( 1 ) print "#\n### SYSTEM INFORMATION\n#" print "# %25s %24d" % ( "[markov states]", tramdata.n_markov_states ) print "# %25s %24d" % ( "[thermodynamic states]", tramdata.n_therm_states ) ############################################################################