Skip to content

Commit

Permalink
update input files
Browse files Browse the repository at this point in the history
  • Loading branch information
roosre committed Jun 10, 2024
1 parent a55b331 commit 55fd787
Show file tree
Hide file tree
Showing 12 changed files with 1,022 additions and 663 deletions.
3 changes: 1 addition & 2 deletions examples/010_harmonic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import matplotlib.pyplot as plt

from ansys.dpf.composites.composite_model import CompositeModel
from ansys.dpf.composites.constants import FailureOutput
from ansys.dpf.composites.constants import FailureOutput, FAILURE_LABEL
from ansys.dpf.composites.example_helper import get_continuous_fiber_example_files
from ansys.dpf.composites.failure_criteria import (
CombinedFailureCriterion,
Expand Down Expand Up @@ -119,7 +119,6 @@
# This is a bit confusing, but DPF uses the same label for Frequency and Time
FREQ_LABEL = "time"
PHASE_LABEL = "phase"
FAILURE_LABEL = "failure_label"
all_phases_and_freqs_failure_value_fc = dpf.FieldsContainer()
all_phases_and_freqs_failure_value_fc.labels = [FREQ_LABEL, PHASE_LABEL]

Expand Down
52 changes: 43 additions & 9 deletions tests/composite_model_scoping_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pytest

from ansys.dpf.composites.composite_model import CompositeModel, CompositeScope
from ansys.dpf.composites.constants import FailureOutput
from ansys.dpf.composites.constants import FailureOutput, FAILURE_LABEL
from ansys.dpf.composites.data_sources import get_composite_files_from_workbench_result_folder
from ansys.dpf.composites.failure_criteria import (
CombinedFailureCriterion,
Expand All @@ -49,13 +49,13 @@ def test_composite_model_element_scope(dpf_server, data_files):

composite_scope = CompositeScope(elements=[1, 3])
failure_container = composite_model.evaluate_failure_criteria(cfc, composite_scope)
irfs = failure_container.get_field({"failure_label": FailureOutput.FAILURE_VALUE})
irfs = failure_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE})
min_id = irfs.scoping.ids[np.argmin(irfs.data)]
max_id = irfs.scoping.ids[np.argmax(irfs.data)]

composite_scope = CompositeScope(elements=[min_id, max_id])
max_container = composite_model.evaluate_failure_criteria(cfc, composite_scope)
max_irfs = max_container.get_field({"failure_label": FailureOutput.FAILURE_VALUE})
max_irfs = max_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE})
assert len(max_irfs.data) == 2
assert max_irfs.get_entity_data_by_id(min_id)[0] == pytest.approx(min(irfs.data), 1e-8)
assert max_irfs.get_entity_data_by_id(max_id)[0] == pytest.approx(max(irfs.data), 1e-8)
Expand All @@ -78,7 +78,7 @@ def test_composite_model_named_selection_scope(dpf_server, data_files, distribut

scope = CompositeScope(named_selections=[ns_name])
failure_container = composite_model.evaluate_failure_criteria(cfc, scope)
irfs = failure_container.get_field({"failure_label": FailureOutput.FAILURE_VALUE})
irfs = failure_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE})
assert len(irfs.data) == 2
assert irfs.get_entity_data_by_id(2) == pytest.approx(1.4792790331384016, 1e-8)
assert irfs.get_entity_data_by_id(3) == pytest.approx(1.3673715033617213, 1e-8)
Expand Down Expand Up @@ -118,8 +118,8 @@ def test_composite_model_ply_scope(dpf_server):

scope = CompositeScope(plies=ply_ids)
failure_container = composite_model.evaluate_failure_criteria(cfc, scope)
irfs = failure_container.get_field({"failure_label": FailureOutput.FAILURE_VALUE})
modes = failure_container.get_field({"failure_label": FailureOutput.FAILURE_MODE})
irfs = failure_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE})
modes = failure_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_MODE})

if version_older_than(dpf_server, "7.0"):
# the old implementation did not allow to distinguish between plies of the different parts.
Expand Down Expand Up @@ -194,8 +194,8 @@ def test_composite_model_named_selection_and_ply_scope(dpf_server, data_files, d

scope = CompositeScope(named_selections=[ns_name], plies=ply_ids)
failure_container = composite_model.evaluate_failure_criteria(cfc, scope)
irfs = failure_container.get_field({"failure_label": FailureOutput.FAILURE_VALUE})
modes = failure_container.get_field({"failure_label": FailureOutput.FAILURE_MODE})
irfs = failure_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE})
modes = failure_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_MODE})
assert len(irfs.data) == 2
assert len(modes.data) == 2
expected_irfs_by_id = {2: 0.49282684, 3: 0.32568454}
Expand Down Expand Up @@ -230,6 +230,40 @@ def test_composite_model_time_scope(dpf_server):
for time, expected_max_irf in time_id_and_expected_max_irf.items():
scope = CompositeScope(time=time)
failure_container = composite_model.evaluate_failure_criteria(cfc, scope)
irfs = failure_container.get_field({"failure_label": FailureOutput.FAILURE_VALUE})
irfs = failure_container.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE})
assert len(irfs.data) == 4
assert max(irfs.data) == pytest.approx(expected_max_irf, abs=1e-6)


def test_ply_wise_scoping_in_assembly_with_imported_solid_model(dpf_server):
"""Ensure that the ply-wise scoping works in combination with the reference surface plot."""
result_folder = pathlib.Path(__file__).parent / "data" / "assemby_imported_solid_model"

composite_files = get_composite_files_from_workbench_result_folder(result_folder)

# Create a composite model
composite_model = CompositeModel(composite_files, dpf_server)

plies = [
"Setup 2_shell::P1L1__ModelingPly.2",
"Setup_solid::P1L1__ModelingPly.2",
"Setup 3_solid::P1L1__ModelingPly.1",
]

# Evaluate combined failure criterion
combined_failure_criterion = CombinedFailureCriterion(failure_criteria=[MaxStressCriterion()])
failure_result = composite_model.evaluate_failure_criteria(
combined_criterion=combined_failure_criterion,
composite_scope=CompositeScope(plies=plies)
)

# check the on reference surface data
for failure_output in [
FailureOutput.FAILURE_VALUE_REF_SURFACE,
FailureOutput.FAILURE_MODE_REF_SURFACE,
FailureOutput.MAX_GLOBAL_LAYER_IN_STACK,
FailureOutput.MAX_LOCAL_LAYER_IN_ELEMENT,
FailureOutput.MAX_SOLID_ELEMENT_ID,
]:
field = failure_result.get_field({FAILURE_LABEL: failure_output})
assert field.size == 21
18 changes: 7 additions & 11 deletions tests/composite_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def test_failure_criteria_evaluation_default_unit_system(dpf_server):
failure_container = composite_model.evaluate_failure_criteria(cfc)


def test_composite_model_with_imported_solid_models(dpf_server):
def test_composite_model_with_imported_solid_model_assembly(dpf_server):
"""
Imported solid models are slightly different if compared with shell parts
and standard solid models. For instance, they have analysis plies which are
Expand All @@ -556,22 +556,19 @@ def test_composite_model_with_imported_solid_models(dpf_server):
an imported solid model which are all
"""
result_folder = pathlib.Path(__file__).parent / "data" / "assemby_imported_solid_model"

# Create the composite files object that contains
# the results file, the material properties file, and the
# composite definitions
composite_files = get_composite_files_from_workbench_result_folder(result_folder)

# Create a composite model
composite_model = CompositeModel(composite_files, dpf_server)

# ensure that all analysis plies are available, also the filler plies
analysis_plies = get_all_analysis_ply_names(composite_model.get_mesh())
ref_plies = [
"Setup 2_shell::P1L1__ModelingPly.2",
"Setup_solid::P1L1__ModelingPly.2",
"Setup 3_solid::P1L1__ModelingPly.1",
"Setup 3_solid::P1L1__ModelingPly.3",
"Setup 3_solid::filler_Structural Steel",
"Setup 3_solid::filler_Epoxy Carbon Woven (230 GPa) Prepreg",
"Setup 3_solid::P1L1__ModelingPly.2",
"Setup 2_shell::P1L1__ModelingPly.1",
"Setup_solid::P1L1__ModelingPly.1",
Expand All @@ -583,16 +580,15 @@ def test_composite_model_with_imported_solid_models(dpf_server):
failure_result = composite_model.evaluate_failure_criteria(combined_failure_criterion)

irf_field = failure_result.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE})
assert irf_field.size == 160

irf_field = failure_result.get_field({FAILURE_LABEL: FailureOutput.FAILURE_VALUE_REF_SURFACE})
assert irf_field.size == 103
assert irf_field.size == 84

# check the on reference surface data
for failure_output in [
FailureOutput.FAILURE_VALUE_REF_SURFACE,
FailureOutput.FAILURE_MODE_REF_SURFACE,
FailureOutput.MAX_GLOBAL_LAYER_IN_STACK,
FailureOutput.MAX_LOCAL_LAYER_IN_ELEMENT,
FailureOutput.MAX_SOLID_ELEMENT_ID,
]:
field = failure_result.get_field({FAILURE_LABEL: failure_output})
assert field.size == 103
assert field.size == 60
Loading

0 comments on commit 55fd787

Please sign in to comment.