hashin_shtrikman_mp
  • Home
  • Examples
    • 3-phase Composite Example
    • Example Visualizations for 2-, 3-, and 4-phase Composites
  • Documentation
    • Genetic Algorithm
      • GeneticAlgorithmParams
      • GeneticAlgorithmResult
      • GeneticAlgorithm
      • Member
      • OptimizationParams
      • Population
    • User Input
      • Aggregate
      • MaterialProperty
      • Material
      • MixtureProperty
      • Mixture
      • UserInput
    • Visualization
      • CompositePropertyPlotter
      • OptimizationResultVisualizer
    • MatchFinder
  • Search
  • Previous
  • Next
  • Edit on Github
  • Example Visualizations for 2-, 3-, and 4-phase Composites
    • 2-phase composite
    • 3-phase composite
    • 4-phase composite

Example Visualizations for 2-, 3-, and 4-phase Composites¶

In [1]:
Copied!
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
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

In [2]:
Copied!
consolidated_dict = {}
with open("test_consolidated_dict") as f:
    consolidated_dict = json.load(f)
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

In [3]:
Copied!
mat_1_ids = ["mp-684591"]
mat_2_ids = ["mp-3098"]
matches_dict = {'mat1': mat_1_ids, 'mat2': mat_2_ids}
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

In [4]:
Copied!
materials = list(matches_dict.values())
material_combinations = list(itertools.product(*materials))
materials = list(matches_dict.values()) material_combinations = list(itertools.product(*materials))

Use the first combination to demonstrate plotting

In [5]:
Copied!
match = material_combinations[0]
match = material_combinations[0]

Create a mock user workflow (similar to the steps in this example)

In [6]:
Copied!
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)
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.

In [7]:
Copied!
visualizer = CompositePropertyPlotter(ga_result)
visualizer.visualize_composite_eff_props(match, consolidated_dict)
visualizer = CompositePropertyPlotter(ga_result) visualizer.visualize_composite_eff_props(match, consolidated_dict)

But here we only include one example:
2-phase

3-phase composite¶

Create example match lists for the two constituent materials

In [8]:
Copied!
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}
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

In [9]:
Copied!
materials = list(matches_dict.values())
material_combinations = list(itertools.product(*materials))
materials = list(matches_dict.values()) material_combinations = list(itertools.product(*materials))

Use the first combination to demonstrate plotting

In [10]:
Copied!
match = material_combinations[0]
match = material_combinations[0]

Create a mock user workflow (similar to the steps in this example)

In [11]:
Copied!
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)
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.

In [12]:
Copied!
visualizer = CompositePropertyPlotter(ga_result)
visualizer.visualize_composite_eff_props(match, consolidated_dict)
visualizer = CompositePropertyPlotter(ga_result) visualizer.visualize_composite_eff_props(match, consolidated_dict)

But here we only include one example:
3-phase

4-phase composite¶

Create example match lists for the two constituent materials

In [13]:
Copied!
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}
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

In [14]:
Copied!
materials = list(matches_dict.values())
material_combinations = list(itertools.product(*materials))
materials = list(matches_dict.values()) material_combinations = list(itertools.product(*materials))

Use the first combination to demonstrate plotting

In [15]:
Copied!
match = material_combinations[-1]
match = material_combinations[-1]

Create a mock user workflow (similar to the steps in this example)

In [16]:
Copied!
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)
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.

In [17]:
Copied!
visualizer = CompositePropertyPlotter(ga_result)
visualizer.visualize_composite_eff_props(match, consolidated_dict)
visualizer = CompositePropertyPlotter(ga_result) visualizer.visualize_composite_eff_props(match, consolidated_dict)

But here we only include one example:
4-phase


Built by Carla Becker, Hrushikesh Sahasrabuddhe, and Max C. Gallant

Documentation built with MkDocs.

Search

From here you can search these documents. Enter your search terms below.

Keyboard Shortcuts

Keys Action
? Open this help
n Next page
p Previous page
s Search