Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated get_constituent_citations #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Updated get_constituent_citations
  • Loading branch information
FusionSandwich authored Aug 8, 2024
commit ebb8682561abc4158d39c571ece31e79fe54adb3
18 changes: 13 additions & 5 deletions material-db-tools/material_db_tools.py
Original file line number Diff line number Diff line change
@@ -16,11 +16,19 @@ def make_mat_from_atom(atom_frac, density, citation):
return mat.expand_elements()


def get_consituent_citations(materials):
citation_str = ""
def get_constituent_citations(materials):
"""
Retrieve citations from a list of materials.

Arguments:
materials (list): A list of Material objects.
Returns:
citation (str): A comma-separated string of citations.
"""
citation_list = []
for mat in materials:
citation_str = " ".join([citation_str, mat.metadata["citation"]])
return citation_str
citation_list.append(mat.metadata["citation"])
return ", ".join(citation_list)


# Mix Materials by Volume
@@ -48,7 +56,7 @@ def mix_by_volume(material_library, vol_fracs, citation, density_factor=1):
mat = mix.mix_by_volume()
mat.density *= density_factor
mat.metadata["mixture_citation"] = citation
mat.metadata["constituent_citation"] = get_consituent_citations(
mat.metadata["constituent_citation"] = get_constituent_citations(
list(mix_dict.keys())
)
return mat