Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NTRfC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFD - Institut für Turbomaschinen und Fluid-Dynamik
tools
NTRfC
Commits
8abff0f9
Commit
8abff0f9
authored
2 years ago
by
Malte Nyhuis
Browse files
Options
Downloads
Patches
Plain Diff
add fluid methods
parent
3a576374
No related branches found
No related tags found
1 merge request
!27
add fluid methods
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ntrfc/fluid/fluid.py
+23
-0
23 additions, 0 deletions
ntrfc/fluid/fluid.py
tests/fluid/test_ntrfc_fluid.py
+10
-1
10 additions, 1 deletion
tests/fluid/test_ntrfc_fluid.py
with
33 additions
and
1 deletion
ntrfc/fluid/fluid.py
+
23
−
0
View file @
8abff0f9
...
...
@@ -120,3 +120,26 @@ def isentropic_total_temperature(kappa, mach_number, temperature):
isentropic_total_temperature
=
temperature
/
(
1
+
(
kappa
-
1
)
/
2
*
mach_number
**
2
)
**
-
1
return
isentropic_total_temperature
def
speed_of_sound
(
*
,
gamma
,
R
=
None
,
p
=
None
,
rho
=
None
,
T
=
None
):
"""
Calculate the speed of sound based on the given equation.
https://www.grc.nasa.gov/www/BGH/isentrop.html
Args:
gamma (float): The specific heat ratio.
p (float): The pressure of the gas.
rho (float): The density of the gas.
R (float): The specific gas constant.
T (float): The temperature of the gas.
Returns:
float: The speed of sound.
"""
if
not
T
and
not
R
:
a
=
np
.
sqrt
(
gamma
*
p
/
rho
)
elif
not
rho
:
a
=
np
.
sqrt
(
gamma
*
R
*
T
)
return
a
This diff is collapsed.
Click to expand it.
tests/fluid/test_ntrfc_fluid.py
+
10
−
1
View file @
8abff0f9
import
numpy
as
np
from
ntrfc.fluid.fluid
import
total_pressure
,
mach_number
,
sutherland_viscosity
,
ma_is
,
isentropic_reynolds_number
,
\
isentropic_total_temperature
isentropic_total_temperature
,
speed_of_sound
def
test_total_pressure
():
...
...
@@ -50,3 +50,12 @@ def test_isentropic_total_temperature():
expected_output
=
315
output
=
isentropic_total_temperature
(
1.4
,
0.5
,
300
)
assert
abs
(
output
-
expected_output
)
<
1e-2
def
test_speed_of_sound
():
assert
abs
(
speed_of_sound
(
gamma
=
1.4
,
p
=
101325
,
rho
=
1.225
)
-
340.29
)
<
0.01
assert
abs
(
speed_of_sound
(
gamma
=
1.3
,
p
=
101325
,
rho
=
1.225
)
-
327.92
)
<
0.01
assert
abs
(
speed_of_sound
(
gamma
=
1.4
,
p
=
80000
,
rho
=
1.225
)
-
302.37
)
<
0.01
assert
abs
(
speed_of_sound
(
gamma
=
1.3
,
p
=
80000
,
rho
=
1.225
)
-
291.37
)
<
0.01
assert
abs
(
speed_of_sound
(
gamma
=
1.4
,
R
=
287.05
,
T
=
288.15
)
-
340.29
)
<
0.01
assert
abs
(
speed_of_sound
(
gamma
=
1.3
,
R
=
287.05
,
T
=
288.15
)
-
327.91
)
<
0.01
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment