I’m trying to evaluate drag and lift coefficient over a cylinder in a “2D” case. I saw that there were already answers for this problem so i tried to manage with hints given here.
By the way, i surely made a mistake in my usproj file as it seems i can’t compile it.
Here are the error messages :
Compiling user subroutines and linking
Traceback (most recent call last):
File “/opt/code_saturne-2.1.0/bin/code_saturne”, line 49, in
retcode = cs.execute()
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_script.py”, line 62, in execute
return self.commandscommand
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_script.py”, line 114, in run
return cs_run.main(options, self.package)
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_run.py”, line 191, in main
save_results=save_results)
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_case.py”, line 1718, in run
mpi_environment)
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_case.py”, line 1348, in prepare_data
d.compile_and_link()
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_case_domain.py”, line 627, in compile_and_link
raise RunCaseError(‘Compile or link error.’)
cs_case_domain.RunCaseError: Compile or link error.
I attach my usproj. Could someone tell me where i’m wrong ? In fact, i’m totally new with subroutines so i’m not sure of the way to use its.
Hello Jean-Marc,
Yes, there is a compilation error of user subroutines (cs_case_domain.RunCaseError: Compile or link error.).
You can see the compilation error messages in the file Compil.log locate in the folder RESU/201111xx-xx/.
You can also test your compilation using the command code_saturne compile -t in your SRC folder.
I think you use correctly user subroutines (copie .c or .f90 from SRC/REFERENCE to SRC/ and modify it), but you need to respect the correct fortran syntax to compile user files. I saw some mistakes in your usproj (uninitialized variables, …), I think you will able to correct them with the compilation error messages. Best regards,
JF
I manage to solve some errors but there are compile error that i don’t understand. In fact i haven’t practive fortran for while and i have lost fortran basics.
So here are the last version of my usproj and my compile.log usproj.f90 (11.3 KB) compile.log (1.53 KB)
/home/caelinux/Desktop/cyl/cyl1/RESU/20111109-1502/src_saturne/usproj.f90:296.38: XCOF(II) = xfor(II)/((1.0d0/2.0d0)RO0(1)UREF(1)**20.025d00.025d0*3.141d0) 1 Error: Expected a right parenthesis in expression at (1) Error: Unexpected end of file in ‘/home/caelinux/Desktop/cyl/cyl1/RESU/20111109-1502/src_saturne/usproj.f90’ gfortran -I/home/caelinux/Desktop/cyl/cyl1/RESU/20111109-1502/src_saturne -I/opt/code_saturne-2.1.0/include/code_saturne -x f95-cpp-input -Wall -Wno-unused -D_CS_FC_HAVE_FLUSH -O -c /home/caelinux/Desktop/cyl/cyl1/RESU/20111109-1502/src_saturne/usproj.f90 usproj.f90 (11.3 KB)
I tool a look at your file, and the error you have is due to RO0 and UREF not being arrays anymore in version 2.1 (iphas has been removed, so RO0(1) is replaced by RO0, and UREF(1) by UREF).
Still, this does not solve everything: your “if /then.. endif” contructs do not match (the first test on ntcabs does not seem to be closed), so I’ll let you solve this on your side (I really recommend indenting your if/endif and loop constructs: it will make the code more readable and easier to debug).
You also need to replace:
ra(iforbf + (ifac-1)*ndim + ii -1)
by:
forbr(ii, ifac)
There may be other errors, but you should solve those first.
First thanks for the ro and uref formulation.
I think that i have solved those errors with the file structure.
By the way, now it seems that another problem comes. Compiling usproj seems to work (i think but not sure).
After compiling and linking there is this error message :
Compiling user subroutines and linking
Preparing calculation data
Traceback (most recent call last):
File “/opt/code_saturne-2.1.0/bin/code_saturne”, line 49, in
retcode = cs.execute()
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_script.py”, line 62, in execute
return self.commandscommand
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_script.py”, line 114, in run
return cs_run.main(options, self.package)
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_run.py”, line 191, in main
save_results=save_results)
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_case.py”, line 1718, in run
mpi_environment)
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_case.py”, line 1363, in prepare_data
d.copy_solver_data()
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_case_domain.py”, line 725, in copy_solver_data
self.copy_data_file(f)
File “/opt/code_saturne-2.1.0/lib/python2.6/site-packages/code_saturne/cs_case_domain.py”, line 215, in copy_data_file
raise RunCaseError(err_str)
cs_case_domain.RunCaseError: ('File: ', ‘usproj.f90’, ‘\ncan not be accessed.’)
Hello,
It seems you added usproj.f90 to the list of user input files, but this list is for files in the DATA directory only, so there is no reason to add it there. Files in SRC are accounted for automatically.
Yvan
Thanks Yvan you’re right i added usproj.f90 in the user file list. I’m really new with subroutines but with your help i’ll not do the same mistakes in the future.
By the way, now i have bad results for the drag coefficient, in my simulation i compute a 10⁴4 reynolds but i find a value near 0.4-0.5 instead of near 1.2 according experience.
I checked the value of Uref and ro0 and it’s ok.
I check if it’s an issue of the grid, but u+ seems ok and twice the number of cells don’t change the results at all.
Results with k-epsilon and k-epsilon linear production with scalable wall function are closed.
Hello,
Did you test the sensibility to mesh refinement or turbulence model ? In many cases, obtaining a good drag coefficient may require a rather fine mesh.
Also, your sum using forbr is a total force, so I would expect your coefficient calculation to include a surface in the denominator, but this does not seem to be the case. Is this normal ?
Best regards,
Yvan
As i wrote in a previous message i have tested the mesh sensibility, and refine the mesh by a factor 3 or even 10 didn’t change the results at all.
Same results with different turbulence model, gradient calculation method or numerical scheme.
Same results for steady or unsteady calculation.
The calculation converged.
I think that the problem was in my Cd formula.
My first formula for Cd was :
xcof(II) = xfor(II)/(0.5d0ro0UREF20.025d0 * 0.025d0 * 3.141d0)
I thought that for an infinte cylinder the area was PiR² (where my radius is 0.025 m)
When i use the next formula using R² as area i obtain good results
xcof(II) = xfor(II)/(0.5d0ro0UREF20.025d0 * 0.025d0)
By the way i’m not sure that it’s the right formula formula as i think it should be :
xcof(II) = xfor(II)/(0.5d0ro0UREF**20.001d0 * 0.05d0)
where 0.001 m is my z thicknes and 0.05 my diameter.
I’ve tried to improve the mesh by refining it, but nothing changes. I still have wrong values for Cd (no change in the value given in my previous post).
Is anyone have an idea of what could be the origin of this problem ?