CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

adding velocity fluctuations on inlet by user fortran

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 17, 2017, 09:47
Default adding velocity fluctuations on inlet by user fortran
  #1
New Member
 
LintaoZhong
Join Date: Mar 2017
Location: Chengdu,China
Posts: 13
Rep Power: 9
Sergeyevichsky is on a distinguished road
Hi all
I want to add velocity fluctuation on inlet by user fortran. Here, thanks Glenn giving me this suggestion. And this is my first time to touch fortran, though I have learned C++ before. After learning fortran roughly, I decide to use the simplest method to generate velocity fluctuations, that is Algebraic methods. The formula is u_i=U_i+r_i*sqrt(2/3*k), where U_i is mean velocity, r_i is random numbers taken from a normal distribution ℵ(0, 1) of mean µ = 0 and variance σ = 1 and k is kinetic energy. Here is code about random number, but I don't know how to add this code into user fortran. What's more. Which user subroutine should I choose in the shared library? How should I add velocity fluctuations generated by user fortran to 2D plane?
**********************************
Module ran_mod
Implicit None
! ran return a uniform random number between 0-1
! norma return a normal distribution
contains
function ran() !returns random number between 0 - 1
implicit none
integer , save :: flag = 0
double precision :: ran
if(flag==0) then
call random_seed()
flag = 1
endif
call random_number(ran) ! built in fortran 90 random number function
end function ran
function normal(mean,sigma)
implicit none
integer :: flag
double precision, parameter :: pi = 3.141592653589793239
double precision :: u1, u2, y1, y2, normal, mean, sigma
save flag
data flag /0/
u1 = ran(); u2 = ran()
if (flag.eq.0) then
y1 = sqrt(-2.0d0*log(u1))*cos(2.0d0*pi*u2)
normal = mean + sigma*y1
flag = 1
else
y2 = sqrt(-2.0d0*log(u1))*sin(2.0d0*pi*u2)
normal = mean + sigma*y2
endif
end function normal
End Module ran_mod
Sergeyevichsky is offline   Reply With Quote

Old   May 17, 2017, 21:51
Default
  #2
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,870
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
There are some tutorial examples on CFX user fortran. They are not with the other tutorials (which are on the ANSYS customer webpage), they are in the CFX Modeling Guide, section 18. They are the place to start with fortran in CFX.
ghorrocks is offline   Reply With Quote

Old   May 18, 2017, 23:42
Default
  #3
New Member
 
LintaoZhong
Join Date: Mar 2017
Location: Chengdu,China
Posts: 13
Rep Power: 9
Sergeyevichsky is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
There are some tutorial examples on CFX user fortran. They are not with the other tutorials (which are on the ANSYS customer webpage), they are in the CFX Modeling Guide, section 18. They are the place to start with fortran in CFX.
Thank you again, Glenn.
Sergeyevichsky is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping over all faces within a boundary condition (turbulent inlet development) Sevex OpenFOAM Programming & Development 5 September 8, 2016 14:58
Pressure problems with inlet variable velocity jaimesdiegop CFX 2 September 1, 2016 03:31
velocity inlet and ideal gas simultaneously-what's wrong? preetam69 FLUENT 0 September 28, 2013 05:51
Variables Definition in CFX Solver 5.6 R P CFX 2 October 26, 2004 03:13
what the result is negatif pressure at inlet chong chee nan FLUENT 0 December 29, 2001 06:13


All times are GMT -4. The time now is 14:56.