Custom material tuning#

This example shows how you can tune a custom material for use with PyAdditive. For background information and file formats, see Material Tuning Tool (Beta) to Create User Defined Materials in the Additive Manufacturing Beta Features documentation. To prevent wasted time, before executing this example, carefully review the steps described in this PyAdditive documentation.

Units are SI (m, kg, s, K) unless otherwise noted.

Perform required import and connect#

Perform the required import and connect to the Additive service.

from ansys.additive.core import Additive, MaterialTuningInput

additive = Additive()
2024-02-21 03:20:04 Connected to localhost:50052
user data path: /home/runner/.local/share/pyadditive

Specify tuning inputs#

The MaterialTuningInput object contains the paths to the files needed to tune a material. The experiment_data_file file is a CSV file containing the results of single bead experiments. The material_configuration_file file is a JSON file containing the material parameters. The thermal_properties_lookup_file file is a CSV file containing the temperature-dependent properties of the material. The characteristic_width_lookup_file file is an optional CSV file containing the melt pool characteristic width at various laser powers and scan speeds. If the characteristic width lookup file is not specified, it is generated during the tuning process.

# Download the example input files.

import ansys.additive.core.examples as examples

input_files = examples.download_material_tuning_input()

# This code includes the characteristic width lookup file to reduce
# processing time. If a characteristic width lookup file is not available,
# the field can be omitted when creating the MaterialTuningInput object.

input = MaterialTuningInput(
    id="custom-material-tuning",
    experiment_data_file=input_files.experiment_data_file,
    material_configuration_file=input_files.material_configuration_file,
    thermal_properties_lookup_file=input_files.thermal_properties_lookup_file,
    characteristic_width_lookup_file=input_files.characteristic_width_lookup_file,
    allowable_error=0.05,  # allowable difference, as a ratio, between experimental and simulated results
    max_iterations=10,  # maximum number of simulation iterations to perform
    base_plate_temperature=353.15,  # only used when calculating the characteristic width
)

Perform material tuning#

Use the tune_material() method to perform material tuning.

summary = additive.tune_material(input)
Tuning started
Reading existing Characteristic Width file: /tmp/additive/4a43e740c2572/input/cw_lookup.csv
Optimizing parameters
Initializing tuned parameter file: /tmp/additive/4a43e740c2572/output/Optimized_Parameters.csv
Optimizing parameters for (Power: 270 W, Velocity: 1.035 m/s, LayerThickness: 3E-05 m, BeamDiameter: 8E-05 m, BaseplateTemperature: 150 C)
Running thermal solver with Extinction Coefficient: 30128.205128205125, Absorptivity: 0.5
Thermal Solver run completed
Simulation (reference width: 0.000284725 m, reference depth: 0.00011703700000000001 m), Experimental (width: 0.0003155 m, depth: 0.000125 m)
Running thermal solver with Extinction Coefficient: 30128.205128205125, Absorptivity: 0.5387584163232964
Thermal Solver run completed
Simulation (reference width: 0.00029615200000000005 m, reference depth: 0.000122122 m), Experimental (width: 0.0003155 m, depth: 0.000125 m)
Running thermal solver with Extinction Coefficient: 30128.205128205125, Absorptivity: 0.5610999027606274
Thermal Solver run completed
Simulation (reference width: 0.000302633 m, reference depth: 0.00012490800000000002 m), Experimental (width: 0.0003155 m, depth: 0.000125 m)
Writing results to results file: /tmp/additive/4a43e740c2572/output/Optimized_Parameters.csv
Tuning completed

Review results#

The MaterialTuningSummary object contains the results of the material tuning process. These results are used in follow-on steps to calculate the material parameters needed by PyAdditive. For more information, see the Additive documentation referred to earlier.

print(summary)
MaterialTuningSummary
input: MaterialTuningInput
id: custom-material-tuning
allowable_error: 0.05
max_iterations: 10
experiment_data_file: /home/runner/.local/share/pyadditive/examples/material_tuning_input/experiment_data.csv
material_configuration_file: /home/runner/.local/share/pyadditive/examples/material_tuning_input/material_parameters.json
thermal_properties_lookup_file: /home/runner/.local/share/pyadditive/examples/material_tuning_input/thermal_lookup.csv
characteristic_width_lookup_file: /home/runner/.local/share/pyadditive/examples/material_tuning_input/characteristic_width_lookup.csv
base_plate_temperature: 353.15

optimized_parameters_file: /home/runner/.local/share/pyadditive/custom-material-tuning/optimized_parameters.csv
characteristic_width_file: /home/runner/.local/share/pyadditive/examples/material_tuning_input/characteristic_width_lookup.csv
log_file: /home/runner/.local/share/pyadditive/custom-material-tuning/log.txt

Total running time of the script: (2 minutes 5.431 seconds)

Gallery generated by Sphinx-Gallery