コード例 #1
0
ファイル: test_marc.py プロジェクト: marc310896/PoreAna
    def test_init_profiles(self):
        self.skipTest("Temporary")

        # Set the cosinus model
        model = pa.CosineModel("output/diff_mc_cyl_s.obj", 6, 10)

        # Check if the initialized profiles are corret
        self.assertEqual(
            np.array_equal(model._diff_bin,
                           np.array([-1.3937803336775594] * model._bin_num)),
            True)
        self.assertEqual(
            np.array_equal(model._df_bin, np.array([0] * model._bin_num)),
            True)
コード例 #2
0
ファイル: test_simple.py プロジェクト: Ajax23/PoreAna
    def test_diffusion_mc_model(self):
        # self.skipTest("Temporary")

        # Check cosine model
        model = pa.CosineModel("output/diff_mc_cyl_s.h5", 6, 10)

        # Check if the initialized profiles are corret
        self.assertTrue(np.array_equal(np.round(model._diff_bin,3), np.array([-3.702] * model._bin_num)))
        self.assertTrue(np.array_equal(model._df_bin, np.array([0] * model._bin_num)))

        # Check step model
        model = pa.StepModel("output/diff_mc_cyl_s.h5", 6, 10)

        # Check if the initialized profiles are corret
        self.assertTrue(np.array_equal(np.round(model._diff_bin,3), np.array([-3.702] * model._bin_num)))
        self.assertEqual(np.array_equal(model._df_bin, np.array([0] * model._bin_num)), True)
コード例 #3
0
ファイル: test_simple.py プロジェクト: Ajax23/PoreAna
    def test_diffusion_mc_box(self):
        # self.skipTest("Temporary")

        # Set Cosine Model for diffusion and energy profile
        model = pa.CosineModel("output/diff_mc_box.h5", 6, 10)

        # Set the MC class and options
        model._len_step = [10, 20, 30, 40, 50]

        # Do the MC alogirthm
        pa.MC().run(model,"output/diff_test_mc_box.h5", nmc_eq=10000, nmc=3000, is_print=False, is_parallel=False)

        # Plot diffusion coefficient over inverse lagtime
        plt.figure()
        diff = pa.diffusion.mc_fit("output/diff_test_mc_box.h5")
        plt.savefig("output/diffusion_fit_box.pdf", format="pdf", dpi=1000)

        # Check if diffusion coefficient is in the range
        self.assertEqual(abs(diff[0] - (10.5) ) < 0.7, True)
コード例 #4
0
ファイル: test_marc.py プロジェクト: marc310896/PoreAna
    def test_init_likelihood(self):
        self.skipTest("Temporary")

        # Set the cosinus model
        model = pa.CosineModel("output/diff_mc_cyl_s.obj", 6, 10)

        # Set the MC class
        MC = pa.MC(model)

        # Set the variable because this happen in the do_mc_cycles function -> not necessary to call to check the likelihood and Check if the initalize likelihood is correct
        MC._len_step = 1
        self.assertEqual(MC.log_likelihood_z(model), -128852.33005868513)

        # Set the variable because this happen in the do_mc_cycles function -> not necessary to call to check the likelihood and Check if the initalize likelihood is correct
        MC._len_step = 2
        self.assertEqual(MC.log_likelihood_z(model), -165354.76731180004)

        # Set the variable because this happen in the do_mc_cycles function -> not necessary to call to check the likelihood and Check if the initalize likelihood is correct
        MC._len_step = 10
        self.assertEqual(MC.log_likelihood_z(model), -258946.70553844847)
コード例 #5
0
ファイル: test_marc.py プロジェクト: marc310896/PoreAna
    def test_mc_pore(self):
        self.skipTest("Temporary")

        # Set Cosine Model for diffusion and energy profile
        model = pa.CosineModel("output/diff_mc_cyl_s.obj", 6, 10)

        # Set the MC class and options
        model._len_step = [10, 20, 30, 40, 50]
        MC = pa.MC(model, 5000, 5000)

        # Do the MC alogirthm
        MC.do_mc_cycles(model, "output/diff_test_mc.obj")

        # Plot diffusion coefficient over inverse lagtime
        plt.figure()
        diff, diff_mean, diff_table = pa.diffusion.diffusion_fit(
            "output/diff_test_mc.obj")
        plt.savefig("output/diffusion_fit.svg", format="svg", dpi=1000)

        # Plot diffusion profile over box length
        plt.figure()
        pa.diffusion.diff_profile("output/diff_test_mc.obj",
                                  infty_profile=True)
        plt.savefig("output/diffusion_profile.svg", format="svg", dpi=1000)

        # Plot free energy profile over box length
        plt.figure()
        pa.diffusion.df_profile("output/diff_test_mc.obj", [10])
        plt.savefig("output/energy_profile.svg", format="svg", dpi=1000)

        # Plot transition matrix as a heat map
        plt.figure()
        pa.diffusion.plot_trans_mat("output/diff_test_mc.obj", 10)
        plt.savefig("output/transition_heatmap.svg", format="svg", dpi=1000)

        # Check if diffusion coefficient is in the range
        self.assertEqual(abs(diff - (1.4 * 10**-9)) < 0.3 * 10**-9, True)
コード例 #6
0
ファイル: test_marc.py プロジェクト: marc310896/PoreAna
    def test_mc_box(self):
        self.skipTest("Temporary")

        # Set Cosine Model for diffusion and energy profile
        model = pa.CosineModel("output/diff_mc_box.obj", 6, 10)

        # Set the MC class and options
        model._len_step = [1, 2, 5, 10, 20, 30, 40, 50]
        MC = pa.MC(model, 1000, 1000)

        # Do the MC alogirthm
        MC.do_mc_cycles(model, "output/diff_test_mc_box.obj")

        # Plot diffusion coefficient over inverse lagtime
        plt.figure()
        diff, diff_mean, diff_table = pa.diffusion.diffusion_fit(
            "output/diff_test_mc_box.obj")
        plt.savefig("output/diffusion_fit_box.svg", format="svg", dpi=1000)

        # Plot diffusion profile over box length
        plt.figure()
        pa.diffusion.diff_profile("output/diff_test_mc_box.obj",
                                  infty_profile=True)
        plt.savefig("output/diffusion_profile_box.svg", format="svg", dpi=1000)

        # Plot free energy profile over box length
        plt.figure()
        pa.diffusion.df_profile("output/diff_test_mc_box.obj", [10])
        plt.savefig("output/energy_profile_box.svg", format="svg", dpi=1000)

        # Plot transition matrix as a heat map
        plt.figure()
        pa.diffusion.plot_trans_mat("output/diff_test_mc_box.obj", 10)
        plt.savefig("output/transition_heatmap_box.svg",
                    format="svg",
                    dpi=1000)
コード例 #7
0
ファイル: test_simple.py プロジェクト: Ajax23/PoreAna
    def test_diffusion_mc_mc(self):
        # self.skipTest("Temporary")

        # Set Cosine Model for diffusion and energy profile
        model = pa.CosineModel("output/diff_mc_cyl_s.h5", 6, 10)

        # Set the variable because this happen in the do_mc_cycles function -> not necessary to call to check the likelihood and Check if the initalize likelihood is correct
        pa.MC._len_step = 1
        self.assertEqual(round(pa.MC()._log_likelihood_z(model),2),-149411.12)
        # Set the variable because this happen in the do_mc_cycles function -> not necessary to call to check the likelihood and Check if the initalize likelihood is correct
        pa.MC._len_step = 2
        self.assertEqual(round(pa.MC()._log_likelihood_z(model),2),-169616.56)
        # Set the variable because this happen in the do_mc_cycles function -> not necessary to call to check the likelihood and Check if the initalize likelihood is correct
        pa.MC._len_step = 10
        self.assertEqual(round(pa.MC()._log_likelihood_z(model),2), -234093.97)

        # Set len_step for MC run test
        model._len_step = [10,20,40]

        #### Test Single ####
        # Do the MC alogirthm
        pa.MC().run(model,"output/diff_test_mc.yml", nmc_eq=1000, nmc=2000, is_print=False, is_parallel=False)

        # Plot diffusion coefficient over inverse lagtime
        diff = pa.diffusion.mc_fit("output/diff_test_mc.yml")
        plt.savefig("output/mc_fit.pdf", format="pdf", dpi=1000)

        # Plot pore diffusion coefficient over inverse lagtime
        plt.figure()
        diff_pore = pa.diffusion.mc_fit("output/diff_test_mc.yml", section="pore")
        plt.savefig("output/mc_fit_pore.pdf", format="pdf", dpi=1000)

        # Check if diffusion coefficient is in the range
        self.assertEqual(abs(diff[0] - (1.6) ) < 0.3, True)
        self.assertEqual(abs(diff_pore[0] - (1.2) ) < 0.3, True)

        #### Test Parallel ####
        # Do the MC alogirthm
        pa.MC().run(model,"output/diff_test_mc.h5", nmc_eq=8000, nmc=2000, is_print=False, is_parallel=True)

        # Plot diffusion coefficient over inverse lagtime
        plt.figure()
        diff = pa.diffusion.mc_fit("output/diff_test_mc.h5")
        plt.savefig("output/mc_fit.pdf", format="pdf", dpi=1000)

        # Plot pore diffusion coefficient over inverse lagtime
        plt.figure()
        diff_pore = pa.diffusion.mc_fit("output/diff_test_mc.h5", section="pore")
        plt.savefig("output/mc_fit_pore.pdf", format="pdf", dpi=1000)

        # Check if diffusion coefficient is in the range
        self.assertEqual(abs(diff[0]-(1.6) ) < 0.3, True)
        self.assertEqual(abs(diff_pore[0]-(1.2) ) < 0.3, True)

        # Test MC output
        # Set Step Model for diffusion and energy profile
        model = pa.StepModel("output/diff_mc_cyl_s.h5", 6, 10, is_print=True)

        # Set Cosine Model for diffusion and energy profile
        model = pa.CosineModel("output/diff_mc_cyl_s.h5", 6, 10, is_print=True)

        ## Set the MC class and options
        model._len_step = [10]

        # Do the MC alogirthm
        pa.MC().run(model,"output/diff_test_mc_spline.h5", nmc_eq=100, nmc=2000, is_print=True, is_parallel=False)
コード例 #8
0
        if ana_props["dens"] or ana_props["diff"]:
            sample = pa.Sample("../_gro/pore.yml", ana_props["traj"], ana_props["mol"], ana_props["atoms"], [1 for x in ana_props["atoms"]])
            if ana_props["dens"]:
                sample.init_density("dens_"+ana_name+".obj", remove_pore_from_res=True)
            if ana_props["diff"]:
                sample.init_diffusion_bin("diff_"+ana_name+".obj", bin_num=35)
            sample.sample(is_parallel=True)

        if ana_props["mc_trans"]:
            sample = pa.Sample(pore["dimensions"], ana_props["traj"], ana_props["mol"], ana_props["atoms"], [1 for x in ana_props["atoms"]])
            sample.init_diffusion_mc("diff_"+ana_name+"_trans.obj", [1, 2, 5, 10, 20, 30, 40, 50, 60, 70])
            sample.sample(is_parallel=True)

        if ana_props["mc"]:
            model = pa.CosineModel("diff_"+ana_name+"_trans.obj", 6, 10)
            pa.MC().run(model, "diff_"+ana_name+"_mc_cos.obj", nmc_eq=1000000, nmc=1000000)

    # Automation
    is_auto = True
    if is_auto:
        # Calculate density - area is given in bins
        dens = pa.density.bins("dens_MOLSHORT.obj", target_dens=TARGETDENS, area=[[10, 90], [10, 50]])

        # Fill and rerun
        num_diff = dens["diff"]
        if num_diff > 10:
            ps.utils.copy("../_fill/fillBackup.sh", "../_fill/fill.sh")
            ps.utils.replace("../_fill/fill.sh", "FILLDENS", str(int(num_diff)))

            os.system("cd ../_fill;sh fill.sh;cd ../min;SUBMITCOMMAND")