Example Visualizations for 2-, 3-, and 4-phase Composites¶
import itertools
import json
from hashin_shtrikman_mp.core.user_input import MaterialProperty, Material, MixtureProperty, Mixture, UserInput
from hashin_shtrikman_mp.core import GeneticAlgorithm
from hashin_shtrikman_mp.core.genetic_algorithm import OptimizationParams
from hashin_shtrikman_mp.core.visualization import CompositePropertyPlotter
Use the limited set of example materials in the file test_consolidated_dict
consolidated_dict = {}
with open("test_consolidated_dict") as f:
consolidated_dict = json.load(f)
2-phase composite¶
Create example match lists for the two constituent materials
mat_1_ids = ["mp-684591"]
mat_2_ids = ["mp-3098"]
matches_dict = {'mat1': mat_1_ids, 'mat2': mat_2_ids}
Identify all of the possible combinations of the material matches
materials = list(matches_dict.values())
material_combinations = list(itertools.product(*materials))
Use the first combination to demonstrate plotting
match = material_combinations[0]
Create a mock user workflow (similar to the steps in this example)
properties_mat_1 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=20, lower_bound=1),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.0001, lower_bound=1e-5),
MaterialProperty(prop='bulk_modulus', upper_bound=100, lower_bound=50),
MaterialProperty(prop='shear_modulus', upper_bound=100, lower_bound=80),
MaterialProperty(prop='universal_anisotropy', upper_bound=2, lower_bound=1),
]
properties_mat_2 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=5, lower_bound=2),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.009, lower_bound=1e-4),
MaterialProperty(prop='bulk_modulus', upper_bound=400, lower_bound=20),
MaterialProperty(prop='shear_modulus', upper_bound=200, lower_bound=100),
MaterialProperty(prop='universal_anisotropy', upper_bound=2.3, lower_bound=1.3),
]
# Define properties for the mixture
properties_mixture = [
MixtureProperty(prop='elec_cond_300k_low_doping', desired_prop=9),
MixtureProperty(prop='therm_cond_300k_low_doping', desired_prop=0.007),
MixtureProperty(prop='bulk_modulus', desired_prop=234),
MixtureProperty(prop='shear_modulus', desired_prop=150),
MixtureProperty(prop='universal_anisotropy', desired_prop=1.5),
]
# Create Material & Mixture instances
mat_1 = Material(name='mat_1', properties=properties_mat_1)
mat_2 = Material(name='mat_2', properties=properties_mat_2)
mixture = Mixture(name='mixture', properties=properties_mixture)
# Initialize UserInput instance with materials and mixtures
user_input= UserInput(materials=[mat_1, mat_2], mixtures=[mixture])
# Create an OptimizationParams instance for testing
optimization = OptimizationParams.from_user_input(user_input)
# Run optimization
ga = GeneticAlgorithm()
ga_result = ga.run(user_input, gen_counter=False)
Now visualize! There are 5 properties of interest in the example user workflow, so there will be 5 plots.
visualizer = CompositePropertyPlotter(ga_result)
visualizer.visualize_composite_eff_props(match, consolidated_dict)
But here we only include one example:
3-phase composite¶
Create example match lists for the two constituent materials
mat_1_ids = ["mp-684591"]
mat_2_ids = ["mp-3098"]
mat_3_ids = ["mp-4391"]
matches_dict = {'mat1': mat_1_ids, 'mat2': mat_2_ids, 'mat3': mat_3_ids}
Identify all of the possible combinations of the material matches
materials = list(matches_dict.values())
material_combinations = list(itertools.product(*materials))
Use the first combination to demonstrate plotting
match = material_combinations[0]
Create a mock user workflow (similar to the steps in this example)
properties_mat_1 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=20, lower_bound=1),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.0001, lower_bound=1e-5),
MaterialProperty(prop='bulk_modulus', upper_bound=100, lower_bound=50),
MaterialProperty(prop='shear_modulus', upper_bound=100, lower_bound=80),
MaterialProperty(prop='universal_anisotropy', upper_bound=2, lower_bound=1),
]
properties_mat_2 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=5, lower_bound=2),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.009, lower_bound=1e-4),
MaterialProperty(prop='bulk_modulus', upper_bound=400, lower_bound=20),
MaterialProperty(prop='shear_modulus', upper_bound=200, lower_bound=100),
MaterialProperty(prop='universal_anisotropy', upper_bound=2.3, lower_bound=1.3),
]
properties_mat_3 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=10, lower_bound=1),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.005, lower_bound=1e-4),
MaterialProperty(prop='bulk_modulus', upper_bound=300, lower_bound=20),
MaterialProperty(prop='shear_modulus', upper_bound=300, lower_bound=100),
MaterialProperty(prop='universal_anisotropy', upper_bound=2.1, lower_bound=0.9),
]
# Define properties for the mixture
properties_mixture = [
MixtureProperty(prop='elec_cond_300k_low_doping', desired_prop=9),
MixtureProperty(prop='therm_cond_300k_low_doping', desired_prop=0.007),
MixtureProperty(prop='bulk_modulus', desired_prop=234),
MixtureProperty(prop='shear_modulus', desired_prop=150),
MixtureProperty(prop='universal_anisotropy', desired_prop=1.5),
]
# Create Material & Mixture instances
mat_1 = Material(name='mat_1', properties=properties_mat_1)
mat_2 = Material(name='mat_2', properties=properties_mat_2)
mat_3 = Material(name='mat_3', properties=properties_mat_3)
mixture = Mixture(name='mixture', properties=properties_mixture)
# Initialize UserInput instance with materials and mixtures
user_input= UserInput(materials=[mat_1, mat_2, mat_3], mixtures=[mixture])
# Create an OptimizationParams instance for testing
optimization = OptimizationParams.from_user_input(user_input)
# Run optimization
ga = GeneticAlgorithm()
ga_result = ga.run(user_input, gen_counter=False)
Now visualize! There are 5 properties of interest in the example user workflow, so there will be 5 plots.
visualizer = CompositePropertyPlotter(ga_result)
visualizer.visualize_composite_eff_props(match, consolidated_dict)
But here we only include one example:
4-phase composite¶
Create example match lists for the two constituent materials
mat_1_ids = ["mp-684591"]
mat_2_ids = ["mp-3098"]
mat_3_ids = ["mp-4391"]
mat_4_ids = ["mp-3536"]
matches_dict = {'mat1': mat_1_ids, 'mat2': mat_2_ids, 'mat3': mat_3_ids, 'mat4': mat_4_ids}
Identify all of the possible combinations of the material matches
materials = list(matches_dict.values())
material_combinations = list(itertools.product(*materials))
Use the first combination to demonstrate plotting
match = material_combinations[-1]
Create a mock user workflow (similar to the steps in this example)
properties_mat_1 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=20, lower_bound=1),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.0001, lower_bound=1e-5),
MaterialProperty(prop='bulk_modulus', upper_bound=100, lower_bound=50),
MaterialProperty(prop='shear_modulus', upper_bound=100, lower_bound=80),
MaterialProperty(prop='universal_anisotropy', upper_bound=2, lower_bound=1),
]
properties_mat_2 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=5, lower_bound=2),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.009, lower_bound=1e-4),
MaterialProperty(prop='bulk_modulus', upper_bound=400, lower_bound=20),
MaterialProperty(prop='shear_modulus', upper_bound=200, lower_bound=100),
MaterialProperty(prop='universal_anisotropy', upper_bound=2.3, lower_bound=1.3),
]
properties_mat_3 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=10, lower_bound=1),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.005, lower_bound=1e-4),
MaterialProperty(prop='bulk_modulus', upper_bound=300, lower_bound=20),
MaterialProperty(prop='shear_modulus', upper_bound=300, lower_bound=100),
MaterialProperty(prop='universal_anisotropy', upper_bound=2.1, lower_bound=0.9),
]
properties_mat_4 = [
MaterialProperty(prop='elec_cond_300k_low_doping', upper_bound=15, lower_bound=1),
MaterialProperty(prop='therm_cond_300k_low_doping', upper_bound=0.005, lower_bound=1e-4),
MaterialProperty(prop='bulk_modulus', upper_bound=400, lower_bound=20),
MaterialProperty(prop='shear_modulus', upper_bound=500, lower_bound=100),
MaterialProperty(prop='universal_anisotropy', upper_bound=3, lower_bound=0.1),
]
# Define properties for the mixture
properties_mixture = [
MixtureProperty(prop='elec_cond_300k_low_doping', desired_prop=9),
MixtureProperty(prop='therm_cond_300k_low_doping', desired_prop=0.007),
MixtureProperty(prop='bulk_modulus', desired_prop=234),
MixtureProperty(prop='shear_modulus', desired_prop=150),
MixtureProperty(prop='universal_anisotropy', desired_prop=1.5),
]
# Create Material & Mixture instances
mat_1 = Material(name='mat_1', properties=properties_mat_1)
mat_2 = Material(name='mat_2', properties=properties_mat_2)
mat_3 = Material(name='mat_3', properties=properties_mat_3)
mat_4 = Material(name='mat_4', properties=properties_mat_4)
mixture = Mixture(name='mixture', properties=properties_mixture)
# Initialize UserInput instance with materials and mixtures
user_input= UserInput(materials=[mat_1, mat_2, mat_3, mat_4], mixtures=[mixture])
# Create an OptimizationParams instance for testing
optimization = OptimizationParams.from_user_input(user_input)
# Run optimization
ga = GeneticAlgorithm()
ga_result = ga.run(user_input, gen_counter=False)
Now visualize! There are 5 properties of interest in the example user workflow, so there will be 5 plots.
visualizer = CompositePropertyPlotter(ga_result)
visualizer.visualize_composite_eff_props(match, consolidated_dict)
But here we only include one example: