Ejemplo n.º 1
0
    def test_get_local_extrema(self):
        ca = ChargeDensityAnalyzer.from_file(self.chgcar_path)
        threshold_frac = random.random()
        threshold_abs_min = random.randrange(2, 14)
        threshold_abs_max = random.randrange(27e2, 28e4)

        # Minima test
        full_list_min = self.ca_FePO4.get_local_extrema(find_min=True, threshold_frac=1.0)
        frac_list_min_frac = self.ca_FePO4.get_local_extrema(find_min=True, threshold_frac=threshold_frac)
        frac_list_min_abs = self.ca_FePO4.get_local_extrema(find_min=True, threshold_abs=threshold_abs_min)

        self.assertAlmostEqual(len(full_list_min) * threshold_frac, len(frac_list_min_frac), delta=1)

        ca.get_local_extrema(find_min=True)
        df_expected = ca.extrema_df[ca.extrema_df["Charge Density"] <= threshold_abs_min]
        self.assertEqual(len(frac_list_min_abs), len(df_expected))

        # Maxima test
        full_list_max = self.ca_FePO4.get_local_extrema(find_min=False, threshold_frac=1.0)
        frac_list_max = self.ca_FePO4.get_local_extrema(find_min=False, threshold_frac=threshold_frac)
        frac_list_max_abs = self.ca_FePO4.get_local_extrema(find_min=False, threshold_abs=threshold_abs_max)

        self.assertAlmostEqual(len(full_list_max) * threshold_frac, len(frac_list_max), delta=1)

        # Local maxima should finds all center of atoms
        self.assertEqual(len(self.ca_FePO4.structure), len(full_list_max))

        ca.get_local_extrema(find_min=False)
        df_expected = ca.extrema_df[ca.extrema_df["Charge Density"] >= threshold_abs_max]
        self.assertEqual(len(frac_list_max_abs), len(df_expected))
Ejemplo n.º 2
0
 def test_sort_sites_by_integrated_chg(self):
     print(self.chgcar_path)
     ca = ChargeDensityAnalyzer.from_file(self.chgcar_path)
     ca.get_local_extrema()
     ca.sort_sites_by_integrated_chg()
     print(ca._extrema_df.iloc[0], 0.5)
     print(ca._extrema_df.iloc[0]["avg_charge_den"])
     self.assertAlmostEqual(ca._extrema_df.iloc[0]["a"], 0.0)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]["b"], 0.5)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]["c"], 0.0)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]["Charge Density"], 1.65288944124)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]["avg_charge_den"], 0.006831484178753711)
Ejemplo n.º 3
0
 def test_sort_sites_by_integrated_chg(self):
     print(self.chgcar_path)
     ca = ChargeDensityAnalyzer.from_file(self.chgcar_path)
     ca.get_local_extrema()
     ca.sort_sites_by_integrated_chg()
     print(ca._extrema_df.iloc[0], 0.5)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['a'], 0.0)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['b'], 0.5)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['c'], 0.0)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['Charge Density'],
                            1.65288944124)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['Int. Charge Density'],
                            0.0018375161626331743)
Ejemplo n.º 4
0
 def test_sort_sites_by_integrated_chg(self):
     print(self.chgcar_path)
     ca = ChargeDensityAnalyzer.from_file(self.chgcar_path)
     ca.get_local_extrema()
     ca.sort_sites_by_integrated_chg()
     print(ca._extrema_df.iloc[0], 0.5)
     print(ca._extrema_df.iloc[0]['avg_charge_den'])
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['a'], 0.0)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['b'], 0.5)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['c'], 0.0)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['Charge Density'],
                            1.65288944124)
     self.assertAlmostEqual(ca._extrema_df.iloc[0]['avg_charge_den'],
                            0.006831484178753711)
Ejemplo n.º 5
0
 def test_from_file(self):
     ca = ChargeDensityAnalyzer.from_file(self.chgcar_path)
     self.assertTrue(isinstance(ca, ChargeDensityAnalyzer))
Ejemplo n.º 6
0
 def test_from_file(self):
     ca = ChargeDensityAnalyzer.from_file(self.chgcar_path)
     self.assertTrue(isinstance(ca, ChargeDensityAnalyzer))