Skip to content

CLEANit/MatSimPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This repo stores Python functions and classes that help materials science tasks with simulations. Particularly for ASE and Networkx, but also with VASP and (WIP) OVITO. A number of these tools were found online and credit is given where possible. If there are any items lacking suitable accreditation please let me know and I will correct them at once.

Edit 04-03-2024: Accreditations and function examples updated. Further documentation pending.

Documentation:

io.py --> File Input/Output

Class CIF_CAR_ASE
Used for converting CIF and Vasp (CONTCAR, POSCAR) files to the ASE atoms object representation. It is typically used as follows, after importing a file in need of conversion.

extracted_CIF = CIF_CAR_ASE(file_path, "FILE_EXTENSION")
ASE_Extracted = extracted_CIF.convert(False)

File extensions in this case are CIF, CONTCAR, or POSCAR, ignoring case. Feeding .convert 'True' will result in an attempt by ASE to create a visualization of the converted atoms object. Please note that at this time, only the default view mode is implemented and it will not run in Google Colab as of last check.

Func pickle_factory
Creates a pickle file when given a file path (and name) string and a list object containing the information to be pickled.

pickle_factory("path/to/your/dir/file.pkl", yourData)

Func can_opener
Unpickles pickle files when provided a file path to a valid pickle file.

importData = can_opener("path/to/your/dir/file.pkl")

slist.py --> String and List

Func trim_nums(string_name, num_pos = 0)
This allows integer values to be picked out from filenames (i.e. "\home\file_1.txt" would return [1]). A specified integer value is used to return an integer found in the filename (i.e. "\home\file_1_2.txt" would return [1] by default, but would return [2] if num_pos = 1). Adapted from resource here

Func pyargmax(l)
Find the argmax in a python list of numbers. Adapted from resource here

Func strainer(someList, indices)
Takes someList and extracts a sub-list containing only entries found in the indices list. Useful for working with lists of objects that cannot simply be converted to numpy arrays or pandas dataframes. Adapted from resource here

Func repeatDataSampler
Pull a user-defined number of samples from a list of consistently-sized ordered categories/repeats (i.e. name1, name2, name3, grade1, grade2, grade3... --> name1, grade1...).

graph.py --> Graph methods

Func init_graph_from_atm
Initializes an unconnected, undirected graph from a provided ASE atoms object.

Func c_subgraph_finder
Takes a graph and returns every connected subgraph it has. Adapted from resource here

Func graph_visual
Produces a labelled matplotlib visualization of a nx graph object.

Func gdegree
Obtains an array counting degrees of nodes present in graph G. Similar but distinct from the G.degree already present in the nx package.

ase.py --> ASE methods

Func vacuum_adjust
Removes a user-specified amount of vacuum from an ASE atoms object and centres the object.

Func composition_identifier
Defines the composition of an ASE atoms object in a paired list output for chemical numbers and symbols.

elem_list, num_list = composition_identifier(atmObjASE)

About

Materials Science Tools for Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages