|
[Sponsors] |
adding velocity fluctuations on inlet by user fortran |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 17, 2017, 09:47 |
adding velocity fluctuations on inlet by user fortran
|
#1 |
New Member
LintaoZhong
Join Date: Mar 2017
Location: Chengdu,China
Posts: 13
Rep Power: 9 |
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 |
|
May 17, 2017, 21:51 |
|
#2 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,870
Rep Power: 144 |
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.
|
|
May 18, 2017, 23:42 |
|
#3 |
New Member
LintaoZhong
Join Date: Mar 2017
Location: Chengdu,China
Posts: 13
Rep Power: 9 |
||
|
|
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 |