Skip to content

Commit 9f36fea

Browse files
feat: Added pcb_material_elasticity option to export_FEA_model() (#656)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent bbc9ffa commit 9f36fea

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feat: Added pcb_material_elasticity option to export_FEA_model()

examples/03-exporting/export_fea_model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import os
4141

42+
from ansys.api.sherlock.v0.SherlockModelService_pb2 import PcbMaterialElasticity
4243
from examples.examples_globals import get_sherlock_tutorial_path, get_temp_dir
4344

4445
from ansys.sherlock.core import launcher
@@ -115,6 +116,7 @@
115116
clear_FEA_database=True,
116117
use_FEA_model_id=True,
117118
coordinate_units="mm",
119+
pcb_material_elasticity=PcbMaterialElasticity.Orthotropic,
118120
)
119121
print(f"FEA model exported successfully to: {fea_export_path}")
120122
except SherlockExportFEAModelError as e:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ classifiers = [
2424
]
2525

2626
dependencies = [
27-
"ansys-api-sherlock==0.1.50",
27+
"ansys-api-sherlock==0.1.51",
2828
"grpcio>=1.17, <1.68.0",
2929
"protobuf>=3.20",
3030
"pydantic>=2.9.2",

src/ansys/sherlock/core/model.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99

1010
try:
1111
import SherlockModelService_pb2
12-
from SherlockModelService_pb2 import MeshType, TraceOutputType
12+
from SherlockModelService_pb2 import MeshType, PcbMaterialElasticity, TraceOutputType
1313
import SherlockModelService_pb2_grpc
1414
except ModuleNotFoundError:
1515
from ansys.api.sherlock.v0 import SherlockModelService_pb2
16-
from ansys.api.sherlock.v0.SherlockModelService_pb2 import MeshType, TraceOutputType
16+
from ansys.api.sherlock.v0.SherlockModelService_pb2 import (
17+
MeshType,
18+
PcbMaterialElasticity,
19+
TraceOutputType,
20+
)
1721
from ansys.api.sherlock.v0 import SherlockModelService_pb2_grpc
1822

1923
from ansys.sherlock.core import LOG
@@ -652,6 +656,7 @@ def export_FEA_model(
652656
clear_FEA_database: bool,
653657
use_FEA_model_id: bool,
654658
coordinate_units: str,
659+
pcb_material_elasticity: PcbMaterialElasticity = PcbMaterialElasticity.Isotropic,
655660
) -> int:
656661
"""
657662
Export a FEA model.
@@ -711,6 +716,9 @@ def export_FEA_model(
711716
Whether to use FEA model ID.
712717
coordinate_units: str
713718
Units of the model coordinates to use when exporting a model.
719+
pcb_material_elasticity: PcbMaterialElasticity
720+
The type of PCB material elasticity to use when exporting a model. The default value is
721+
``PcbMaterialElasticity.Isotropic``.
714722
715723
716724
Returns
@@ -720,6 +728,7 @@ def export_FEA_model(
720728
721729
Examples
722730
--------
731+
>>> from ansys.api.sherlock.v0.SherlockModelService_pb2 import PcbMaterialElasticity
723732
>>> from ansys.sherlock.core.launcher import launch_sherlock
724733
>>> from ansys.sherlock.core.types.common_types import (
725734
Measurement,
@@ -751,7 +760,8 @@ def export_FEA_model(
751760
display_model=True,
752761
clear_FEA_database=True,
753762
use_FEA_model_id=True,
754-
coordinate_units="mm"
763+
coordinate_units="mm",
764+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic
755765
)
756766
"""
757767
try:
@@ -834,6 +844,7 @@ def export_FEA_model(
834844
export_request.clearFEADatabase = clear_FEA_database
835845
export_request.useFEAModelID = use_FEA_model_id
836846
export_request.coordinateUnits = coordinate_units
847+
export_request.pcbMaterialElasticity = pcb_material_elasticity
837848

838849
return_code = self.stub.exportFEAModel(export_request)
839850
if return_code.value != 0:

tests/test_model.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import platform
55
import unittest
66

7+
from ansys.api.sherlock.v0.SherlockModelService_pb2 import PcbMaterialElasticity
78
import grpc
89
import pytest
910

@@ -315,6 +316,7 @@ def test_export_FEA_model(self):
315316
clear_FEA_database=True,
316317
use_FEA_model_id=True,
317318
coordinate_units="mm",
319+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
318320
)
319321
pytest.fail("No exception raised for invalid project name")
320322
except SherlockExportFEAModelError as e:
@@ -348,8 +350,9 @@ def test_export_FEA_model(self):
348350
clear_FEA_database=True,
349351
use_FEA_model_id=True,
350352
coordinate_units="mm",
353+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
351354
)
352-
pytest.fail("No exception raised for invalid project name")
355+
pytest.fail("No exception raised for invalid CCA name")
353356
except SherlockExportFEAModelError as e:
354357
assert str(e) == "Export FEA model error: CCA name is invalid."
355358

@@ -381,8 +384,9 @@ def test_export_FEA_model(self):
381384
clear_FEA_database=True,
382385
use_FEA_model_id=True,
383386
coordinate_units="mm",
387+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
384388
)
385-
pytest.fail("No exception raised for invalid project name")
389+
pytest.fail("No exception raised for invalid file path")
386390
except SherlockExportFEAModelError as e:
387391
assert str(e) == "Export FEA model error: Export file path is invalid."
388392

@@ -414,8 +418,9 @@ def test_export_FEA_model(self):
414418
clear_FEA_database=True,
415419
use_FEA_model_id=True,
416420
coordinate_units="mm",
421+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
417422
)
418-
pytest.fail("No exception raised for invalid project name")
423+
pytest.fail("No exception raised for invalid file directory")
419424
except SherlockExportFEAModelError as e:
420425
assert str(e) == f'Export FEA model error: Export file directory "test" does not exist.'
421426

@@ -447,8 +452,9 @@ def test_export_FEA_model(self):
447452
clear_FEA_database=True,
448453
use_FEA_model_id=True,
449454
coordinate_units="mm",
455+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
450456
)
451-
pytest.fail("No exception raised for invalid project name")
457+
pytest.fail("No exception raised for invalid minimum hole diameter")
452458
except SherlockExportFEAModelError as e:
453459
assert str(e) == "Export FEA model error: Minimum hole diameter is invalid."
454460

@@ -480,8 +486,9 @@ def test_export_FEA_model(self):
480486
clear_FEA_database=True,
481487
use_FEA_model_id=True,
482488
coordinate_units="mm",
489+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
483490
)
484-
pytest.fail("No exception raised for invalid project name")
491+
pytest.fail("No exception raised for invalid maximum edge length")
485492
except SherlockExportFEAModelError as e:
486493
assert str(e) == "Export FEA model error: Maximum edge length is invalid."
487494

@@ -513,8 +520,9 @@ def test_export_FEA_model(self):
513520
clear_FEA_database=True,
514521
use_FEA_model_id=True,
515522
coordinate_units="mm",
523+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
516524
)
517-
pytest.fail("No exception raised for invalid project name")
525+
pytest.fail("No exception raised for invalid maximum mesh size")
518526
except SherlockExportFEAModelError as e:
519527
assert str(e) == "Export FEA model error: Maximum mesh size is invalid."
520528

@@ -546,8 +554,9 @@ def test_export_FEA_model(self):
546554
clear_FEA_database=True,
547555
use_FEA_model_id=True,
548556
coordinate_units="mm",
557+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
549558
)
550-
pytest.fail("No exception raised for invalid project name")
559+
pytest.fail("No exception raised for invalid vertical mesh size")
551560
except SherlockExportFEAModelError as e:
552561
assert str(e) == "Export FEA model error: Vertical mesh size is invalid."
553562

@@ -580,8 +589,9 @@ def test_export_FEA_model(self):
580589
clear_FEA_database=True,
581590
use_FEA_model_id=True,
582591
coordinate_units="mm",
592+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
583593
)
584-
pytest.fail("No exception raised for invalid project name")
594+
pytest.fail("No exception raised for invalid CCA name")
585595
except Exception as e:
586596
assert type(e) == SherlockExportFEAModelError
587597

@@ -613,6 +623,7 @@ def test_export_FEA_model(self):
613623
clear_FEA_database=False,
614624
use_FEA_model_id=False,
615625
coordinate_units="mm",
626+
pcb_material_elasticity=PcbMaterialElasticity.Isotropic,
616627
)
617628
assert result == 0
618629

0 commit comments

Comments
 (0)