|
[Sponsors] |
July 7, 2017, 13:50 |
Fortran random number generator
|
#1 |
New Member
Join Date: Jun 2017
Posts: 3
Rep Power: 8 |
Good evening,
I am new to CFD and I am working on a fibrous filter simulation. I use CEL expressions to create cylinders with a randomzied orientation. In order to get that randomization I thought about a Fortran subroutine which can create random numbers ([0,1)). Since I am not really good at coding, I have looked for already existing codes and found some Fortran codes for random number generators (e.g. Mersenne-Twister). I created new enviromental variables for windows, used the Intel compiler and got two files (a .dll and .O). And now I have two questions: 1. I always start CFX with the workbench but where do I need to put the files? I put the files in the folder ANSYS creates for my project but I guess that is wrong because I get the error message: | Message: | | Unable to load symbol <file name> from ..\winnt-amd64\<file name>.dll: | The specified procedure could not be found. 2. Or do I need an extra Fortran code that is compatible with CFX? I hope somebody can help me with this problem and thanks in advance. Last edited by Jogginghose; July 10, 2017 at 08:19. |
|
July 9, 2017, 08:09 |
|
#2 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143 |
Doesn't your fortran compiler have a random number generator built in? All the compilers I have seen have one. Then you don't need an external library.
Have a look in the CFX documentation for examples of linking fortran to CFX. |
|
July 10, 2017, 07:03 |
|
#3 |
New Member
Join Date: Jun 2017
Posts: 3
Rep Power: 8 |
Thanks for your help so far, I will have look.
|
|
July 24, 2017, 12:49 |
|
#4 |
New Member
Join Date: Jun 2017
Posts: 3
Rep Power: 8 |
Hey,
my random number generator is working quite well now; I used the intrinsic subroutine RANDOM_NUMBER of Fortran. But I still have one problem: When I use the User Function I get an array of random numbers between (0,1), but I need just one number (or an array with the same number everywhere). I tried several things, the furthest I got was one random number and every other number was my function argument (e.g Function 1(0.25)). I would appreciate some tips from somebody who has more experience than me in Fortran. Thanks in advance. PS: I attached my fortran source code and pictures for the two cases above. I used the velocity to test my subroutine. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Foam::error::PrintStack | almir | OpenFOAM Running, Solving & CFD | 91 | December 21, 2022 04:50 |
[Other] Can't Shake Erros: patch type 'patch' not constraint type 'empty' | BrendaEM | OpenFOAM Meshing & Mesh Conversion | 12 | April 3, 2022 18:32 |
[snappyHexMesh] sHM layer process keeps getting killed | MBttR | OpenFOAM Meshing & Mesh Conversion | 4 | August 15, 2016 03:21 |
decomposePar -allRegions | stru | OpenFOAM Pre-Processing | 2 | August 25, 2015 03:58 |
foam-extend_3.1 decompose and pyfoam warning | shipman | OpenFOAM | 3 | July 24, 2014 08:14 |