sigml.utils package

Submodules

sigml.utils.leg_lib module

sigml.utils.utils module

sigml.utils.utils.build_data(atoms, leg_lmax=30, sig_texts=None, efs=None, radial_cutoff=3.0, device='cpu')

Build a dataset from a list of atoms and optional self-energy text files and fermi energies

Parameters:
  • atoms (list of tg.data.Data objects) – The atoms to build the dataset from

  • sig_texts (list of str, optional, default = None) – The self-energy text files to build the dataset from

  • efs (list of float, optional, default = None) – The fermi energies to build the dataset from

  • radial_cutoff (float, default = 3.0) – The radial cutoff to build the dataset from

  • device (str, default = "cpu") – The device to build the dataset on

Returns:

dataset – The dataset built from the atoms, self-energy text files, and fermi energies

Return type:

list of tg.data.Data objects

sigml.utils.utils.evaluate_ef(model, dataset_org)

Evaluate the \(E_f\) of model on a dataset

Parameters:
  • model (sigml.models.Ef_Model.Ef_Model) – The \(E_f\) model to evaluate

  • dataset_org (list of tg.data.Data objects) – The dataset to evaluate the \(E_f\) on

Return type:

None

sigml.utils.utils.evaluate_full_sig(model, dataset_org, orbital, atom=1, display=True, img_save_dir=None)

Evaluate the \(\Sigma(i\omega_n)\) of model on a dataset. CAUTION: This function is depreciated. Use evaluate_full_sig_legendre instead.

Parameters:
  • model (sigml.models.Sig_iws_Model.Sig_iws_Model) – The \(\Sigma(i\omega_n)\) model to evaluate

  • dataset_org (list of tg.data.Data objects) – The dataset to evaluate the \(\Sigma(i\omega_n)\) on

  • orbital (int, default = 0) – The orbital to evaluate the \(\Sigma(i\omega_n)\) on

  • atom (int, default = 0) – The atom number to evaluate the \(\Sigma(i\omega_n)\) on. The atom number must match a unique correlated atom, symmetrically equivalent atoms are not considered

  • display (bool, default = True) – Whether or not to display the plot. If false, img_save_dir must be provided

  • img_save_dir (str, default = None) – The directory to save the plot if not displayed

  • device (str, default = "cpu") – The device to evaluate the model on

Return type:

None

sigml.utils.utils.evaluate_full_sig_legendre(model, dataset_org, orbital, atom=0, N=3, display=True, img_save_dir=None)

Evaluate the \(\Sigma(i\omega_n)\) of model on a dataset

Parameters:
  • model (sigml.models.Sig_iws_Model.Sig_iws_Model) – The \(\Sigma(i\omega_n)\) model to evaluate

  • dataset_org (list of tg.data.Data objects) – The dataset to evaluate the \(\Sigma(i\omega_n)\) on

  • orbital (int, default = 0) – The orbital to evaluate the \(\Sigma(i\omega_n)\) on

  • atom (int, default = 0) – The atom number to evaluate the \(\Sigma(i\omega_n)\) on. The atom number must match a unique correlated atom, symmetrically equivalent atoms are not considered

  • N (int, default = 3) – The grid size to display results (N x N grid)

  • display (bool, default = True) – Whether or not to display the plot. If false, img_save_dir must be provided

  • img_save_dir (str, default = None) – The directory to save the plot if not displayed

  • device (str, default = "cpu") – The device to evaluate the model on

Return type:

None

sigml.utils.utils.evaluate_sinf(model, dataset_org, display=True, img_save_dir=None, device='cpu')

Evaluate the \(\Sigma_{\infty}\) of model on a dataset

Parameters:
  • model (sigml.models.Sinf_Model.Sinf_Model) – The \(\Sigma_{\infty}\) model to evaluate

  • dataset_org (list of tg.data.Data objects) – The dataset to evaluate the \(\Sigma_{\infty}\) on

  • display (bool, default = True) – Whether or not to display the plot. If false, img_save_dir must be provided

  • img_save_dir (str, default = None) – The directory to save the plot if not displayed

  • device (str, default = "cpu") – The device to evaluate the model on

Return type:

None

sigml.utils.utils.get_average_neighbor_count(all_data)

Gets the average number of neighbors for a given dataset

Parameters:

all_data (list) – A list of tg.data.Data objects

Returns:

avg_neighbor_count – The average number of neighbors for the dataset

Return type:

float

sigml.utils.utils.get_sig_file_text(iws, sig, sinf, U, J, nf)

Generate sig.inp file text for input into EDMFTF

Parameters:
  • iws (np.ndarray) – Matsubara frequencies over which $Sigma$ is defined

  • sig (np.ndarray of shape (N_inequivalent_atoms, N_matsubara, N_orbitals)) – The complex valued self-energy

  • sinf (np.ndarray of shape (N_inequivalent_atoms*N_orbitals)) – Self-energy at infinite frequency

  • U (float) – The columb interaction strength in eV to be used in the DMFT calculation

  • J (float) – The Hund’s coupling in eV to be used in the DMFT calculation

  • nf (float) – The nominal occupancy of the correlated sites

Returns:

lines – A list of all the relevant lines needed to construct the sig.inp text file

Return type:

list of strings

sigml.utils.utils.parse_sig_file(sig_text, orbital='d')

Parses the sig file text from EDMFTF and returns the matsubara frequencies, the self energy data, and the self energy data at infinite frequency

Parameters:
  • sig_text (str) – The text from the sig file

  • orbital (str, default = "d") – The orbital to parse, either “d” or “f”

Returns:

  • iws (np.ndarray) – The matsubara frequencies (upper half of complex plane)

  • sig_data (np.ndarray) – The self energy data

  • sinfs (np.ndarray) – The self energy data at infinite frequency

sigml.utils.utils.train_ef(model, optimizer, dataset, loss_fn, scheduler, save_path=None, max_iter=101, val_percent=0.1, device='cpu', batch_size=1)

Train the \(E_f\) model on a dataset

Parameters:
  • model (sigml.models.Ef_Model.Ef_Model) – The \(E_f\) model to evaluate

  • optimizer (torch.optim.Optimizer) – The optimizer to use for training

  • dataset (list of tg.data.Data objects) – The dataset to train the \(E_f\) on

  • loss_fn (torch.nn.Module) – The loss function to use for training

  • scheduler (torch.optim.lr_scheduler) – The scheduler to use for training

  • save_path (str, default = None) – The path to save the model. If None, the model will not be saved in a directory

  • max_iter (int, default = 101) – The maximum number of iterations to train for

  • val_percent (float, default = 0.1) – The percentage of the dataset to use for validation, expressed as a fraction of the total dataset

  • device (str, default = "cpu") – The device to train the model on

  • batch_size (int, default = 1) – The batch size to use for training. Currently, only a batch size of 1 is supported

Return type:

None

sigml.utils.utils.train_full_sig(model, optimizer, dataset, loss_fn, scheduler, save_path=None, max_iter=101, val_percent=0.1, device='cpu', batch_size=1)

Train the \(\Sigma(i\omega_n)\) model on a dataset

Parameters:
  • model (sigml.models.Sig_iws_Model.Sig_iws_Model) – The \(\Sigma(i\omega_n)\) model to evaluate

  • optimizer (torch.optim.Optimizer) – The optimizer to use for training

  • dataset (list of tg.data.Data objects) – The dataset to train the \(\Sigma(i\omega_n)\) on

  • loss_fn (torch.nn.Module) – The loss function to use for training

  • scheduler (torch.optim.lr_scheduler) – The scheduler to use for training

  • save_path (str, default = None) – The path to save the model. If None, the model will not be saved in a directory

  • max_iter (int, default = 101) – The maximum number of iterations to train for

  • val_percent (float, default = 0.1) – The percentage of the dataset to use for validation, expressed as a fraction of the total dataset

  • device (str, default = "cpu") – The device to train the model on

  • batch_size (int, default = 1) – The batch size to use for training. Currently, only a batch size of 1 is supported

Return type:

None

sigml.utils.utils.train_sinf(model, optimizer, dataset, loss_fn, scheduler, save_path=None, max_iter=101, val_percent=0.1, device='cpu', batch_size=1)

Train the \(\Sigma_{\infty}\) model on a dataset

Parameters:
  • model (sigml.models.Sinf_Model.Sinf_Model) – The \(\Sigma_{\infty}\) model to evaluate

  • optimizer (torch.optim.Optimizer) – The optimizer to use for training

  • dataset (list of tg.data.Data objects) – The dataset to train the \(\Sigma_{\infty}\) on

  • loss_fn (torch.nn.Module) – The loss function to use for training

  • scheduler (torch.optim.lr_scheduler) – The scheduler to use for training

  • save_path (str, default = None) – The path to save the model. If None, the model will not be saved in a directory

  • max_iter (int, default = 101) – The maximum number of iterations to train for

  • val_percent (float, default = 0.1) – The percentage of the dataset to use for validation, expressed as a fraction of the total dataset

  • device (str, default = "cpu") – The device to train the model on

Return type:

None

sigml.utils.utils.train_test_split(dataset, train_percent=0.9, seed=None)

Splits a dataset into training and test sets

Parameters:
  • dataset (list) – A list of tg.data.Data objects

  • train_percent (float, default = 0.9) – The percentage of the dataset to use for training

  • seed (int, default = None) – The seed to use for the random number generator

Returns:

  • train_data (list) – The training data

  • test_data (list) – The test data

sigml.utils.utils_nequip module

Module contents