Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fixed tutorial cases #607

Merged
merged 13 commits into from
Dec 5, 2024
28 changes: 28 additions & 0 deletions examples/migration_guide/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Migration Guide

This folder contains useful tools to help migrating your old cases to use the latest Flow360 V2 API.

## List of tools:

1. BET Disk converter - given a json case config file, extracts information about BET Disks and converts it to match the new version

## How to use BET Disk converter

Import the `bet_disk_convert` function from `bet_disk_converter` file, which is located in migration_guide folder.

The function takes in the following inputs:
- file
- save
- length_unit
- angle_unit
- omega_unit

and returns a tuple of lists:
- list of BET Disks
- list of Cylinder entities used for BET Disks

In order to save the BET Disk and Cylinder files as jsons, be sure to set `save=True`.

The files will appear in your current working directory.

They can later be used to create BET Disk 3D model on WebUI.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from examples.migration_guide.bet_disk import bet_disk_convert
from examples.migration_guide.bet_disk_converter import bet_disk_convert
from flow360.component.simulation.unit_system import u
from flow360.component.simulation.units import flow360_angular_velocity_unit

Expand Down
5 changes: 1 addition & 4 deletions examples/tutorials/fork_cloud_case.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import flow360 as fl
from flow360 import u

fl.Env.preprod.active()

project = fl.Project.from_cloud("PROJECT_ID_HERE")

Expand All @@ -10,6 +7,6 @@
param: fl.SimulationParams = parent_case.params

# fork with new angle of attack being 1.23 degrees
param.operating_condition.alpha = 1.23 * u.deg
param.operating_condition.alpha = 1.23 * fl.u.deg

project.run_case(params=param, fork_from=parent_case, name="Forked case with new alpha")
8 changes: 2 additions & 6 deletions examples/tutorials/quick_start.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Import necessary modules from the Flow360 library
import flow360 as fl
from flow360 import SI_unit_system, u
from flow360.examples import Airplane

# Activate the pre-production environment because of beta testing status
fl.Env.preprod.active()

# Step 1: Create a new project from a predefined geometry file in the Airplane example
# This initializes a project with the specified geometry and assigns it a name.
project = fl.Project.from_file(Airplane.geometry, name="Python Project (Geometry, from file)")
Expand All @@ -18,7 +14,7 @@
geo.group_faces_by_tag("groupName")

# Step 4: Define simulation parameters within a specific unit system
with SI_unit_system:
with fl.SI_unit_system:
# Define an automated far-field boundary condition for the simulation
far_field_zone = fl.AutomatedFarfield()

Expand All @@ -37,7 +33,7 @@
# Operating conditions: setting speed and angle of attack for the simulation
operating_condition=fl.AerospaceCondition(
velocity_magnitude=100, # Velocity of 100 m/s
alpha=5 * u.deg, # Angle of attack of 5 degrees
alpha=5 * fl.u.deg, # Angle of attack of 5 degrees
),
# Time-stepping configuration: specifying steady-state with a maximum step limit
time_stepping=fl.Steady(max_steps=1000),
Expand Down
14 changes: 8 additions & 6 deletions examples/tutorials/tutorial_2D_30p30n.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import flow360 as fl
from flow360.component.simulation.unit_system import SI_unit_system, u
from flow360.examples import Tutorial2D30p30n

fl.Env.preprod.active()

Tutorial2D30p30n.get_files()

project = fl.Project.from_file(Tutorial2D30p30n.geometry, name="Tutorial 2D 30p30n from Python")
Expand All @@ -15,7 +12,7 @@
geometry.group_edges_by_tag("edgeName")


with SI_unit_system:
with fl.SI_unit_system:
cylinders = [
fl.Cylinder(
name=f"cylinder{i+1}",
Expand All @@ -35,7 +32,7 @@
defaults=fl.MeshingDefaults(
surface_edge_growth_rate=1.17,
surface_max_edge_length=1.1,
curvature_resolution_angle=12 * u.deg,
curvature_resolution_angle=12 * fl.u.deg,
boundary_layer_growth_rate=1.17,
boundary_layer_first_layer_thickness=4.9536767e-06,
),
Expand Down Expand Up @@ -78,7 +75,12 @@
moment_center=[0.25, 0, 0], moment_length=[1, 1, 1], area=0.01
),
operating_condition=fl.operating_condition_from_mach_reynolds(
mach=0.17, reynolds=1.71e06, temperature=288.16, alpha=8.5 * u.deg, beta=0 * u.deg
mach=0.17,
reynolds=1.71e06,
project_length_unit=1 * fl.u.m,
temperature=288.16,
alpha=8.5 * fl.u.deg,
beta=0 * fl.u.deg,
),
time_stepping=fl.Steady(
max_steps=3000, CFL=fl.RampCFL(initial=20, final=300, ramp_steps=500)
Expand Down
14 changes: 8 additions & 6 deletions examples/tutorials/tutorial_2D_crm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import flow360 as fl
from flow360.component.simulation.unit_system import SI_unit_system, u
from flow360.examples import Tutorial2DCRM

fl.Env.preprod.active()

Tutorial2DCRM.get_files()

project = fl.Project.from_file(Tutorial2DCRM.geometry, name="Tutorial 2D CRM from Python")
Expand All @@ -15,7 +12,7 @@
geometry.group_edges_by_tag("edgeName")


with SI_unit_system:
with fl.SI_unit_system:
cylinders = [
fl.Cylinder(
name=f"cylinder{i+1}",
Expand All @@ -35,7 +32,7 @@
defaults=fl.MeshingDefaults(
surface_edge_growth_rate=1.17,
surface_max_edge_length=1.1,
curvature_resolution_angle=12 * u.deg,
curvature_resolution_angle=12 * fl.u.deg,
boundary_layer_growth_rate=1.17,
boundary_layer_first_layer_thickness=1.8487111e-06,
),
Expand Down Expand Up @@ -78,7 +75,12 @@
moment_center=[0.25, 0, 0], moment_length=[1, 1, 1], area=0.01
),
operating_condition=fl.operating_condition_from_mach_reynolds(
mach=0.2, reynolds=5e6, temperature=272.1, alpha=16 * u.deg, beta=0 * u.deg
mach=0.2,
reynolds=5e6,
project_length_unit=1 * fl.u.m,
temperature=272.1,
alpha=16 * fl.u.deg,
beta=0 * fl.u.deg,
),
time_stepping=fl.Steady(
max_steps=3000, CFL=fl.RampCFL(initial=20, final=300, ramp_steps=500)
Expand Down
14 changes: 8 additions & 6 deletions examples/tutorials/tutorial_2D_gaw2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import flow360 as fl
from flow360.component.simulation.unit_system import SI_unit_system, u
from flow360.examples import Tutorial2DGAW2

fl.Env.preprod.active()

Tutorial2DGAW2.get_files()

project = fl.Project.from_file(Tutorial2DGAW2.geometry, name="Tutorial 2D GA(W)-2 from Python")
Expand All @@ -15,7 +12,7 @@
geometry.group_edges_by_tag("edgeName")


with SI_unit_system:
with fl.SI_unit_system:
cylinders = [
fl.Cylinder(
name=f"cylinder{i+1}",
Expand All @@ -35,7 +32,7 @@
defaults=fl.MeshingDefaults(
surface_edge_growth_rate=1.17,
surface_max_edge_length=1.1,
curvature_resolution_angle=12 * u.deg,
curvature_resolution_angle=12 * fl.u.deg,
boundary_layer_growth_rate=1.12,
boundary_layer_first_layer_thickness=2.8089171e-06,
),
Expand Down Expand Up @@ -78,7 +75,12 @@
moment_center=[0.25, 0, 0], moment_length=[1, 1, 1], area=0.01
),
operating_condition=fl.operating_condition_from_mach_reynolds(
mach=0.13, reynolds=2.2e06, temperature=288.16, alpha=4 * u.deg, beta=0 * u.deg
mach=0.13,
reynolds=2.2e06,
project_length_unit=1 * fl.u.m,
temperature=288.16,
alpha=4 * fl.u.deg,
beta=0 * fl.u.deg,
),
time_stepping=fl.Steady(
max_steps=3000, CFL=fl.RampCFL(initial=20, final=300, ramp_steps=500)
Expand Down
28 changes: 3 additions & 25 deletions examples/tutorials/tutorial_BET_Disk.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import json

import flow360 as fl
import flow360.component.simulation.units as u
from flow360.component.simulation.unit_system import SI_unit_system
from flow360.examples import TutorialBETDisk

"""
In this tutorial case we are using Blade Element Theory (BET) to simulate the XV-15 rotor blade. Documentation for this tutorial is available in the link below.

https://docs.flexcompute.com/projects/flow360/en/latest/tutorials/BETTutorial/BETTutorial.html
"""


fl.Env.preprod.active()

TutorialBETDisk.get_files()

project = fl.Project.from_file(TutorialBETDisk.geometry, name="Tutorial BETDisk from Python")
Expand All @@ -27,7 +16,7 @@

bet = json.loads(open(TutorialBETDisk.extra["disk0"]).read())

with SI_unit_system:
with fl.SI_unit_system:
cylinder1 = fl.Cylinder(
name="cylinder1",
axis=[1, 0, 0],
Expand All @@ -50,7 +39,7 @@
defaults=fl.MeshingDefaults(
surface_edge_growth_rate=1.2,
surface_max_edge_length=0.5,
curvature_resolution_angle=30 * u.deg,
curvature_resolution_angle=30 * fl.u.deg,
boundary_layer_growth_rate=1.15,
boundary_layer_first_layer_thickness=1e-06,
),
Expand Down Expand Up @@ -96,18 +85,7 @@
),
operating_condition=fl.AerospaceCondition.from_mach(
mach=0.182,
alpha=5 * u.deg,
beta=0 * u.deg,
thermal_state=fl.ThermalState(
temperature=288.15,
material=fl.Air(
dynamic_viscosity=fl.Sutherland(
reference_temperature=288.15,
reference_viscosity=4.29166e-08 * u.flow360_viscosity_unit,
effective_temperature=110.4,
)
),
),
alpha=5 * fl.u.deg,
reference_mach=0.54,
),
time_stepping=fl.Steady(
Expand Down
27 changes: 5 additions & 22 deletions examples/tutorials/tutorial_RANS_xv15.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import math

import flow360 as fl
from flow360.examples import TutorailRANSXv15

fl.Env.preprod.active()
from flow360.examples import TutorialRANSXv15

TutorailRANSXv15.get_files()
TutorialRANSXv15.get_files()
project = fl.Project.from_file(
TutorailRANSXv15.mesh_filename,
TutorialRANSXv15.mesh_filename,
name="Tutorial Time-accurate RANS CFD on XV-15 from Python",
)
volume_mesh = project.volume_mesh
Expand All @@ -16,29 +12,16 @@
rotation_zone = volume_mesh["innerRotating"]
rotation_zone.center = (0, 0, 0) * fl.u.m
rotation_zone.axis = (0, 0, -1)
farfield = fl.AutomatedFarfield(name="farfield")
thermal_state = fl.ThermalState(
temperature=288.15,
material=fl.Air(
dynamic_viscosity=fl.Sutherland(
reference_temperature=288.15,
reference_viscosity=4.29279e-8 * fl.u.flow360_viscosity_unit,
effective_temperature=110.4,
)
),
)
params = fl.SimulationParams(
reference_geometry=fl.ReferenceGeometry(
moment_center=(0, 0, 0),
moment_length=(3.81, 3.81, 3.81),
area=45.604,
),
operating_condition=fl.AerospaceCondition(
velocity_magnitude=5.0 * fl.u.m / fl.u.s,
reference_velocity_magnitude=0.7 * thermal_state.speed_of_sound,
velocity_magnitude=5,
alpha=-90 * fl.u.deg,
beta=0 * fl.u.deg,
thermal_state=thermal_state,
reference_velocity_magnitude=238.14,
),
time_stepping=fl.Unsteady(
max_pseudo_steps=35,
Expand Down
8 changes: 3 additions & 5 deletions examples/tutorials/tutorial_auto_meshing_internal_flow.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import flow360 as fl
from flow360.examples import TutorailAutoMeshingInternalFlow
from flow360.examples import TutorialAutoMeshingInternalFlow

fl.Env.preprod.active()

TutorailAutoMeshingInternalFlow.get_files()
TutorialAutoMeshingInternalFlow.get_files()
project = fl.Project.from_file(
TutorailAutoMeshingInternalFlow.geometry, name="Tutorial Auto Meshing Internal Flow from Python"
TutorialAutoMeshingInternalFlow.geometry, name="Tutorial Auto Meshing Internal Flow from Python"
)
geometry = project.geometry

Expand Down
15 changes: 1 addition & 14 deletions examples/tutorials/tutorial_cht_solver.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
import flow360 as fl
from flow360.examples import TutorialCHTSolver

fl.Env.preprod.active()

TutorialCHTSolver.get_files()
project = fl.Project.from_file(
TutorialCHTSolver.mesh_filename, name="Tutorial CHT Solver from Python"
)
volume_mesh = project.volume_mesh

with fl.SI_unit_system:
thermal_state = fl.ThermalState(
temperature=288.15 * fl.u.K,
material=fl.Air(
dynamic_viscosity=fl.Sutherland(
reference_temperature=288.15 * fl.u.K,
reference_viscosity=4.2925193198151646e-8 * fl.u.flow360_viscosity_unit,
effective_temperature=110.4 * fl.u.K,
)
),
)
operating_condition = fl.AerospaceCondition().from_mach(mach=0.1, thermal_state=thermal_state)
params = fl.SimulationParams(
reference_geometry=fl.ReferenceGeometry(
moment_center=[0, 0, 0] * fl.u.m,
moment_length=[1, 1, 1] * fl.u.m,
area=1 * fl.u.m**2,
),
operating_condition=operating_condition,
operating_condition=fl.AerospaceCondition.from_mach(mach=0.1),
time_stepping=fl.Steady(
max_steps=10000, CFL=fl.RampCFL(initial=1, final=100, ramp_steps=1000)
),
Expand Down
Loading
Loading