Esempio n. 1
0
    def __init__(self, path=None):
        """
        Construct a CASM ProjectSettings representation.

        Args:
            path: path to CASM project (Default=None, uses project containing current directory). 

        """
        if project_path(path) is None:
            if path is None:
                raise Exception("No CASM project found using " + os.getcwd())
            else:
                raise Exception("No CASM project found using " + path)
        self.path = project_path(path)
        dir = DirectoryStructure(self.path)
        self.data = json.load(open(dir.project_settings()))

        d = self.data["cluster_expansions"][self.data["default_clex"]]
        self._default_clex = ClexDescription(d["name"], d["property"], d["calctype"], d["ref"], d["bset"], d["eci"])

        self._clex = [
            ClexDescription(d[1]["name"], d[1]["property"], d[1]["calctype"], d[1]["ref"], d[1]["bset"], d[1]["eci"])
            for d in self.data["cluster_expansions"].iteritems()
        ]

        d = self.data["cluster_expansions"].get("formation_energy", None)
        self._formation_energy_clex = None
        if d is not None:
            self._formation_energy_clex = ClexDescription(
                d["name"], d["property"], d["calctype"], d["ref"], d["bset"], d["eci"]
            )
Esempio n. 2
0
    def __init__(self, path=None):
        """
        Construct a CASM ProjectSettings representation.

        Args:
            path: path to CASM project (Default=None, uses project containing current directory). 

        """
        if project_path(path) is None:
            if path is None:
                raise Exception("No CASM project found using " + os.getcwd())
            else:
                raise Exception("No CASM project found using " + path)
        self.path = project_path(path)
        dir = DirectoryStructure(self.path)
        self.data = json.load(open(dir.project_settings()))

        d = self.data["cluster_expansions"][self.data["default_clex"]]
        self._default_clex = ClexDescription(d["name"], d["property"],
                                             d["calctype"], d["ref"],
                                             d["bset"], d["eci"])

        self._clex = [
            ClexDescription(d[1]["name"], d[1]["property"], d[1]["calctype"],
                            d[1]["ref"], d[1]["bset"], d[1]["eci"])
            for d in self.data["cluster_expansions"].iteritems()
        ]

        d = self.data["cluster_expansions"].get("formation_energy", None)
        self._formation_energy_clex = None
        if d is not None:
            self._formation_energy_clex = ClexDescription(
                d["name"], d["property"], d["calctype"], d["ref"], d["bset"],
                d["eci"])
Esempio n. 3
0
    def __init__(self, path=None, casm_exe=None, verbose=True):
        """
      Construct a CASM Project representation.

      Arguments
      ----------
        
        path: str, optional, default=None 
          Path to project root directory. Default=None uses project containing 
          current working directory
        
        casm_exe: str, optional, default=None
          CASM executable to use for command line interface. Default
          uses $CASM if it exists in the environment, else "casm".
        
        verbose: bool, optional, default=True
          How much to print to stdout
      
      """

        # will hold a ctypes.c_void_p when loading CASM project into memory
        self._ptr = None

        # will keep a casm.API instance
        self._api = None

        # set path to this CASM project
        if project_path(path) is None:
            if path is None:
                raise Exception("No CASM project found using " + os.getcwd())
            else:
                raise Exception("No CASM project found using " + path)

        # set executable name
        if casm_exe is None:
            if "CASM" in os.environ:
                casm_exe = os.environ["CASM"]
            else:
                casm_exe = "casm"

        self.path = project_path(path)
        self.__refresh()
        self.casm_exe = casm_exe
        self.verbose = verbose

        self.all_composition_axes = {}
        if os.path.exists(self.dir.composition_axes()):
            with open(self.dir.composition_axes(), 'r') as f:
                data = json.load(f)
                if "standard_axes" in data:
                    for key, val in data["standard_axes"].iteritems():
                        self.all_composition_axes[key] = CompositionAxes(
                            key, val)
                if "custom_axes" in data:
                    for key, val in data["custom_axes"].iteritems():
                        self.all_composition_axes[key] = CompositionAxes(
                            key, val)
                self.composition_axes = self.all_composition_axes[
                    data["current_axes"]]
Esempio n. 4
0
    def __init__(self, path=None, casm_exe=None, verbose=True):
        """
      Construct a CASM Project representation.

      Arguments
      ----------
        
        path: str, optional, default=None 
          Path to project root directory. Default=None uses project containing 
          current working directory
        
        casm_exe: str, optional, default=None
          CASM executable to use for command line interface. Default
          uses $CASM if it exists in the environment, else "casm".
        
        verbose: bool, optional, default=True
          How much to print to stdout
      
      """

        # will hold a ctypes.c_void_p when loading CASM project into memory
        self._ptr = None

        # will keep a casm.API instance
        self._api = None

        # set path to this CASM project
        if project_path(path) is None:
            if path is None:
                raise Exception("No CASM project found using " + os.getcwd())
            else:
                raise Exception("No CASM project found using " + path)

        # set executable name
        if casm_exe is None:
            if "CASM" in os.environ:
                casm_exe = os.environ["CASM"]
            else:
                casm_exe = "casm"

        self.path = project_path(path)
        self.__refresh()
        self.casm_exe = casm_exe
        self.verbose = verbose
Esempio n. 5
0
    def __init__(self, path=None, casm_exe=None, verbose=True):
        """
      Construct a CASM Project representation.

      Arguments
      ----------
        
        path: str, optional, default=None 
          Path to project root directory. Default=None uses project containing 
          current working directory
        
        casm_exe: str, optional, default=None
          CASM executable to use for command line interface. Default
          uses $CASM if it exists in the environment, else "casm".
        
        verbose: bool, optional, default=True
          How much to print to stdout
      
      """

        # will hold a ctypes.c_void_p when loading CASM project into memory
        self._ptr = None

        # will keep a casm.API instance
        self._api = None

        # set path to this CASM project
        if project_path(path) is None:
            if path is None:
                raise Exception("No CASM project found using " + os.getcwd())
            else:
                raise Exception("No CASM project found using " + path)

        # set executable name
        if casm_exe is None:
            if "CASM" in os.environ:
                casm_exe = os.environ["CASM"]
            else:
                casm_exe = "casm"

        self.path = project_path(path)
        self.__refresh()
        self.casm_exe = casm_exe
        self.verbose = verbose
Esempio n. 6
0
    def __init__(self, path=None):
        """
        Construct a CASM Project DirectoryStructure representation.

        Args:
            path: path to CASM project (Default=None, uses project containing current directory). 

        """
        if project_path(path) is None:
            if path is None:
                raise Exception("No CASM project found using " + os.getcwd())
            else:
                raise Exception("No CASM project found using " + path)
        self.path = project_path(path)
        self.__casm_dir = ".casm"
        self.__bset_dir = "basis_sets"
        self.__calc_dir = "training_data"
        self.__set_dir = "settings"
        self.__sym_dir = "symmetry"
        self.__clex_dir = "cluster_expansions"
Esempio n. 7
0
    def __init__(self, path=None):
        """
        Construct a CASM Project DirectoryStructure representation.

        Args:
            path: path to CASM project (Default=None, uses project containing current directory). 

        """
        if project_path(path) is None:
            if path is None:
                raise Exception("No CASM project found using " + os.getcwd())
            else:
                raise Exception("No CASM project found using " + path)
        self.path = project_path(path)
        self.__casm_dir = ".casm"
        self.__bset_dir = "basis_sets"
        self.__calc_dir = "training_data"
        self.__set_dir = "settings"
        self.__sym_dir = "symmetry"
        self.__clex_dir = "cluster_expansions"