|
14 | 14 | SherlockRunAnalysisError, |
15 | 15 | SherlockRunStrainMapAnalysisError, |
16 | 16 | SherlockUpdateHarmonicVibePropsError, |
| 17 | + SherlockUpdateICTAnalysisPropsError, |
17 | 18 | SherlockUpdateMechanicalShockPropsError, |
18 | 19 | SherlockUpdateNaturalFrequencyPropsError, |
19 | 20 | SherlockUpdatePartModelingPropsError, |
@@ -42,6 +43,10 @@ def __init__(self, channel): |
42 | 43 | "forceModelRebuild": "force_model_rebuild", |
43 | 44 | "harmonicVibeDamping": "harmonic_vibe_damping", |
44 | 45 | "harmonicVibeCount": "harmonic_vibe_count", |
| 46 | + "ictApplicationTime": "ict_application_time", |
| 47 | + "ictApplicationTimeUnits": "ict_application_time_units", |
| 48 | + "ictNumberOfEvents": "ict_number_of_events", |
| 49 | + "ictResultCount": "ict_result_count", |
45 | 50 | "modelSource": "model_source", |
46 | 51 | "naturalFreqCount": "natural_freq_count", |
47 | 52 | "naturalFreqMin": "natural_freq_min", |
@@ -333,7 +338,7 @@ def update_harmonic_vibe_props( |
333 | 338 |
|
334 | 339 | if "cca_name" not in harmonic_vibe_props.keys(): |
335 | 340 | raise SherlockUpdateHarmonicVibePropsError( |
336 | | - message=f"CCA name is invalid for harmonic vibe properties {i}." |
| 341 | + message=f"CCA name is missing for harmonic vibe properties {i}." |
337 | 342 | ) |
338 | 343 |
|
339 | 344 | cca_name = harmonic_vibe_props["cca_name"] |
@@ -483,6 +488,183 @@ def update_harmonic_vibe_props( |
483 | 488 | LOG.error(str(e)) |
484 | 489 | raise e |
485 | 490 |
|
| 491 | + def get_ict_analysis_input_fields(self): |
| 492 | + """Get ICT analysis property fields based on the user configuration. |
| 493 | +
|
| 494 | + Parameters |
| 495 | + ---------- |
| 496 | + None |
| 497 | +
|
| 498 | + Returns |
| 499 | + ------- |
| 500 | + list |
| 501 | + List of ICT analysis property fields based on the user configuration. |
| 502 | +
|
| 503 | + Examples |
| 504 | + -------- |
| 505 | + >>> from ansys.sherlock.core.launcher import launch_sherlock |
| 506 | + >>> sherlock = launch_sherlock() |
| 507 | + >>> sherlock.analysis.get_ict_analysis_input_fields() |
| 508 | + """ |
| 509 | + if not self._is_connection_up(): |
| 510 | + LOG.error("There is no connection to a gRPC service.") |
| 511 | + return |
| 512 | + |
| 513 | + message = SherlockAnalysisService_pb2.GetICTAnalysisInputFieldsRequest() |
| 514 | + response = self.stub.getICTAnalysisInputFields(message) |
| 515 | + |
| 516 | + fields = self._translate_field_names(response.fieldName) |
| 517 | + LOG.info(fields) |
| 518 | + |
| 519 | + return fields |
| 520 | + |
| 521 | + def update_ict_analysis_props( |
| 522 | + self, |
| 523 | + project, |
| 524 | + ict_analysis_properties, |
| 525 | + ): |
| 526 | + """Update properties for an ICT analysis. |
| 527 | +
|
| 528 | + Parameters |
| 529 | + ---------- |
| 530 | + project : str |
| 531 | + Name of the Sherlock project. |
| 532 | + ict_analysis_properties : list |
| 533 | + List of ICT analysis properties for a CCA consisting of these properties: |
| 534 | +
|
| 535 | + - cca_name : str |
| 536 | + Name of the CCA. |
| 537 | + - ict_application_time : double |
| 538 | + Specifies the amount of time to complete one ICT event. |
| 539 | + - ict_application_time_units : str |
| 540 | + Application time units. |
| 541 | + Options are ``"ms"``, ``"sec"``, ``"min"``, ``"hr"``, ``"day"``, ``"year"``. |
| 542 | + - ict_number_of_events: int |
| 543 | + Specifies the number of events to apply to the application time when computing |
| 544 | + the time to failure for a component. |
| 545 | + - part_validation_enabled: bool |
| 546 | + Whether to enable part validation. The default is ``None``. |
| 547 | + - require_material_assignment_enabled: bool |
| 548 | + Whether to require material assignment. The default is ``None``. |
| 549 | + - ict_result_count: int |
| 550 | + The number of ICT result layers to generate. This parameter is for use with |
| 551 | + thermal analysis. |
| 552 | +
|
| 553 | + Returns |
| 554 | + ------- |
| 555 | + int |
| 556 | + Status code of the response. 0 for success. |
| 557 | +
|
| 558 | + Examples |
| 559 | + -------- |
| 560 | + >>> from ansys.sherlock.core.launcher import launch_sherlock |
| 561 | + >>> sherlock = launch_sherlock() |
| 562 | + >>> sherlock.project.import_odb_archive( |
| 563 | + "ODB++ Tutorial.tgz", |
| 564 | + True, |
| 565 | + True, |
| 566 | + True, |
| 567 | + True, |
| 568 | + project="Test", |
| 569 | + cca_name="Card", |
| 570 | + ) |
| 571 | + >>> sherlock.analysis.update_ict_analysis_props( |
| 572 | + "Test", |
| 573 | + [{ |
| 574 | + 'cca_name': 'Card', |
| 575 | + 'ict_application_time': 2, |
| 576 | + 'ict_application_time_units': 'sec', |
| 577 | + 'ict_number_of_events': 10, |
| 578 | + 'part_validation_enabled': False, |
| 579 | + 'require_material_assignment_enabled': False, |
| 580 | + }, |
| 581 | + ] |
| 582 | + ) |
| 583 | +
|
| 584 | + """ |
| 585 | + try: |
| 586 | + if project == "": |
| 587 | + raise SherlockUpdateICTAnalysisPropsError(message="Project name is invalid.") |
| 588 | + |
| 589 | + if not isinstance(ict_analysis_properties, list): |
| 590 | + raise SherlockUpdateICTAnalysisPropsError( |
| 591 | + message="ICT analysis properties argument is invalid." |
| 592 | + ) |
| 593 | + |
| 594 | + if len(ict_analysis_properties) == 0: |
| 595 | + raise SherlockUpdateICTAnalysisPropsError( |
| 596 | + message="One or more ICT analysis properties are required." |
| 597 | + ) |
| 598 | + |
| 599 | + request = SherlockAnalysisService_pb2.UpdateICTAnalysisPropsRequest(project=project) |
| 600 | + |
| 601 | + for i, ict_analysis_props in enumerate(ict_analysis_properties): |
| 602 | + if not isinstance(ict_analysis_props, dict): |
| 603 | + raise SherlockUpdateICTAnalysisPropsError( |
| 604 | + f"ICT analysis props argument is invalid for ICT analysis properties {i}." |
| 605 | + ) |
| 606 | + |
| 607 | + if "cca_name" not in ict_analysis_props.keys(): |
| 608 | + raise SherlockUpdateICTAnalysisPropsError( |
| 609 | + message=f"CCA name is missing for ICT analysis properties {i}." |
| 610 | + ) |
| 611 | + |
| 612 | + cca_name = ict_analysis_props["cca_name"] |
| 613 | + if cca_name == "": |
| 614 | + raise SherlockUpdateICTAnalysisPropsError( |
| 615 | + message=f"CCA name is invalid for ICT analysis properties {i}." |
| 616 | + ) |
| 617 | + |
| 618 | + props_request = request.ictAnalysisProperties.add() |
| 619 | + props_request.ccaName = cca_name |
| 620 | + |
| 621 | + if "ict_analysis_count" in ict_analysis_props.keys(): |
| 622 | + props_request.ictAnalysisCount = ict_analysis_props["ict_analysis_count"] |
| 623 | + |
| 624 | + if "ict_application_time" in ict_analysis_props.keys(): |
| 625 | + props_request.applicationTime = ict_analysis_props["ict_application_time"] |
| 626 | + |
| 627 | + if "ict_application_time_units" in ict_analysis_props.keys(): |
| 628 | + props_request.applicationTimeUnits = ict_analysis_props[ |
| 629 | + "ict_application_time_units" |
| 630 | + ] |
| 631 | + |
| 632 | + if "ict_number_of_events" in ict_analysis_props.keys(): |
| 633 | + props_request.numberOfEvents = ict_analysis_props["ict_number_of_events"] |
| 634 | + |
| 635 | + if "part_validation_enabled" in ict_analysis_props.keys(): |
| 636 | + props_request.partValidationEnabled = ict_analysis_props[ |
| 637 | + "part_validation_enabled" |
| 638 | + ] |
| 639 | + |
| 640 | + if "require_material_assignment_enabled" in ict_analysis_props.keys(): |
| 641 | + props_request.requireMaterialAssignmentEnabled = ict_analysis_props[ |
| 642 | + "require_material_assignment_enabled" |
| 643 | + ] |
| 644 | + |
| 645 | + if "force_model_rebuild" in ict_analysis_props.keys(): |
| 646 | + props_request.forceModelRebuild = ict_analysis_props["force_model_rebuild"] |
| 647 | + |
| 648 | + except SherlockUpdateICTAnalysisPropsError as e: |
| 649 | + LOG.error(str(e)) |
| 650 | + raise e |
| 651 | + |
| 652 | + if not self._is_connection_up(): |
| 653 | + LOG.error("There is no connection to a gRPC service.") |
| 654 | + return |
| 655 | + |
| 656 | + response = self.stub.updateICTAnalysisProps(request) |
| 657 | + |
| 658 | + try: |
| 659 | + if response.value == -1: |
| 660 | + raise SherlockUpdateICTAnalysisPropsError(response.message) |
| 661 | + else: |
| 662 | + LOG.info(response.message) |
| 663 | + return response.value |
| 664 | + except SherlockUpdateICTAnalysisPropsError as e: |
| 665 | + LOG.error(str(e)) |
| 666 | + raise e |
| 667 | + |
486 | 668 | def get_mechanical_shock_input_fields(self, model_source=None): |
487 | 669 | """Get mechanical shock property fields based on the user configuration. |
488 | 670 |
|
|
0 commit comments