|
| 1 | +import flow360.component.simulation.units as u |
| 2 | +from flow360.component.simulation.draft_context.coordinate_system_manager import ( |
| 3 | + CoordinateSystemAssignmentGroup, |
| 4 | + CoordinateSystemEntityRef, |
| 5 | + CoordinateSystemStatus, |
| 6 | +) |
| 7 | +from flow360.component.simulation.entity_operation import CoordinateSystem |
| 8 | +from flow360.component.simulation.framework.param_utils import AssetCache |
| 9 | +from flow360.component.simulation.models.volume_models import ( |
| 10 | + BETDisk, |
| 11 | + BETDiskChord, |
| 12 | + BETDiskSectionalPolar, |
| 13 | + BETDiskTwist, |
| 14 | +) |
| 15 | +from flow360.component.simulation.primitives import Cylinder |
| 16 | +from flow360.component.simulation.simulation_params import SimulationParams |
| 17 | +from flow360.component.simulation.translator.utils import ( |
| 18 | + apply_coordinate_system_transformations, |
| 19 | +) |
| 20 | +from flow360.component.simulation.unit_system import SI_unit_system |
| 21 | + |
| 22 | + |
| 23 | +def test_apply_coordinate_system_transformations_skips_frozen_non_entity_sequences(): |
| 24 | + with SI_unit_system: |
| 25 | + cylinder = Cylinder( |
| 26 | + name="bet_disk", |
| 27 | + center=(0, 0, 0) * u.m, |
| 28 | + axis=(0, 0, 1), |
| 29 | + height=1 * u.m, |
| 30 | + outer_radius=1 * u.m, |
| 31 | + ) |
| 32 | + bet_disk = BETDisk( |
| 33 | + entities=cylinder, |
| 34 | + rotation_direction_rule="leftHand", |
| 35 | + number_of_blades=3, |
| 36 | + omega=100 * u.rpm, |
| 37 | + chord_ref=1 * u.m, |
| 38 | + n_loading_nodes=20, |
| 39 | + mach_numbers=[0], |
| 40 | + reynolds_numbers=[1000000], |
| 41 | + twists=[BETDiskTwist(radius=0 * u.m, twist=0 * u.deg)], |
| 42 | + chords=[BETDiskChord(radius=0 * u.m, chord=1 * u.m)], |
| 43 | + alphas=[-2, 0, 2] * u.deg, |
| 44 | + sectional_radiuses=[0.25, 0.5] * u.m, |
| 45 | + sectional_polars=[ |
| 46 | + BETDiskSectionalPolar( |
| 47 | + lift_coeffs=[[[0.1, 0.2, 0.3]]], |
| 48 | + drag_coeffs=[[[0.01, 0.02, 0.03]]], |
| 49 | + ), |
| 50 | + BETDiskSectionalPolar( |
| 51 | + lift_coeffs=[[[0.15, 0.25, 0.35]]], |
| 52 | + drag_coeffs=[[[0.015, 0.025, 0.035]]], |
| 53 | + ), |
| 54 | + ], |
| 55 | + ) |
| 56 | + coordinate_system = CoordinateSystem(name="cs", translation=(1, 2, 3) * u.m) |
| 57 | + coordinate_system_status = CoordinateSystemStatus( |
| 58 | + coordinate_systems=[coordinate_system], |
| 59 | + parents=[], |
| 60 | + assignments=[ |
| 61 | + CoordinateSystemAssignmentGroup( |
| 62 | + coordinate_system_id=coordinate_system.private_attribute_id, |
| 63 | + entities=[ |
| 64 | + CoordinateSystemEntityRef( |
| 65 | + entity_type="Cylinder", |
| 66 | + entity_id=cylinder.private_attribute_id, |
| 67 | + ) |
| 68 | + ], |
| 69 | + ) |
| 70 | + ], |
| 71 | + ) |
| 72 | + params = SimulationParams( |
| 73 | + models=[bet_disk], |
| 74 | + private_attribute_asset_cache=AssetCache( |
| 75 | + coordinate_system_status=coordinate_system_status, |
| 76 | + ), |
| 77 | + ) |
| 78 | + |
| 79 | + apply_coordinate_system_transformations(params) |
| 80 | + |
| 81 | + transformed_bet_disk = params.models[0] |
| 82 | + transformed_cylinder = transformed_bet_disk.entities.stored_entities[0] |
| 83 | + |
| 84 | + assert all(transformed_cylinder.center == [1, 2, 3] * u.m) |
| 85 | + assert transformed_bet_disk.mach_numbers == [0] |
| 86 | + assert transformed_bet_disk.twists[0].radius == 0 * u.m |
| 87 | + assert transformed_bet_disk.chords[0].chord == 1 * u.m |
0 commit comments