Outputing mass or volumetric flowrate

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
sbardwell

Outputing mass or volumetric flowrate

Post by sbardwell »

Hello,

I have currently created a model of a labyrinth seal and would like to output directly the flow rates from the calculation process. To start with i have tried to develop a user extra operation to compute the mass flow rate at the exit boundary and another section in the seal and export them into a .dat file (although ideally i would prefer a .csv file).

this is the current error i am receiving:
cs_user_extra_operations-global_efforts.o: dans la fonction « cs_f_user_extra_operations_ »:
cs_user_extra_operations-global_efforts.f90:(.text+0x53): référence indéfinie vers « ifluma_ »
cs_user_extra_operations-global_efforts.f90:(.text+0x7e): référence indéfinie vers « ifluma_ »
cs_user_extra_operations-global_efforts.f90:(.text+0x500): référence indéfinie vers « ifluma_ »
collect2: error: ld returned 1 exit status


Except i cannot find anywhere on the Doxygen website any variables to extract the flow rate so i re-used some variables i found on an old post. This is what i thought was possible to get the field values :

call field_get_val_v(ifluma(iw), flumab)
call field_get_val_v(ifluma(iw), flumas)


Further in the script i loop on the cells on the surface to retrieve the total sum by readapting an old script i found on the forum:

call getfbr('outlet', nlelt,lstelt)

do ilelt = 1, nlelt
ifac = lstelt(ilelt)
massout = massout + flumab(ifac, iflmab)
enddo


I've added my scripts below if someone could please help it would be great :)

Thanks
Attachments
compile.log
(5.33 KiB) Downloaded 266 times
cs_user_extra_operations-global_efforts.f90
(6.2 KiB) Downloaded 248 times
CTrinca
Posts: 32
Joined: Mon Mar 30, 2015 9:19 am

Re: Outputing mass or volumetric flowrate

Post by CTrinca »

Hello,

I hope someone more expert will correct me if I am wrong, but I think that, in the new versions, the mass flux can be retrieved using the field_get_key_int as in the examples cs_user_extra_operations-energy_balance.f90 and cs_user_extra_operations-energy_balance.f90:

Code: Select all

call field_get_key_int(ivarfl(ivar), kimasf, iflmas)
"kimasf" should be the key for the mass flux across internal faces, while "kbmasf" should work for boundary faces.
Hope this is not completely wrong.
Regards,

Cosimo
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: Outputing mass or volumetric flowrate

Post by Yvan Fournier »

Hello,

Yes, using call field_get_key_int(ivarfl(ivar), kimasf, iflmas) will allow you to retreive the field id for the mass flux (in iflmas). You can then use field_get_val_s to obtain access to the values.

Regards,

Yvan
sbardwell

Re: Outputing mass or volumetric flowrate

Post by sbardwell »

Thank you both for your quick answers, it helped me solve my problems. I have another question now concerning the calling of boundaries or surfaces.

Is it possible to use the function call getfbr('z=0', nlelt, lstelt) like in the GUI for calling certain zones or boundaries or must we use a named/colored surface for the function to work properly ? because now i am getting an error in the listing file like this :
Error parsing expression:
z = 0
^
Opérateur attendu au lieu d'une opérande.


Regards,

Sean
CTrinca
Posts: 32
Joined: Mon Mar 30, 2015 9:19 am

Re: Outputing mass or volumetric flowrate

Post by CTrinca »

Hello,

Again, I am hardly an experienced user so I would not bet my money on this, but according to the user manual you can use inequality symbols to select cells and faces, so you can use, for instance, the strings 'z <= 1' or ' -1 < z < 1' but it seems you cannot use the 'equal' symbol. Anyway, the user manual lists all the possibilities, you could look there to find the one that works best for you.
I hope this helps.
Regards,

Cosimo
sbardwell

Re: Outputing mass or volumetric flowrate

Post by sbardwell »

Thanks again!! I found the page in the user guide with all the possible definitions at page 51. There is more possibilities than what i thought!

Thanks a lot for your help its been really helpful!!

best regards,

Sean
sbardwell

Re: Outputing mass or volumetric flowrate

Post by sbardwell »

Hello again,

Sorry if this is a stupid question, I'm new to coding in Fortran. In my User extra operations file I'm trying to export the Data to .csv file (which works so far) but it only writes the last time-step, when i looked into it, the script overwrites the values at each time-step and i know cs_user_extra_operations is loaded at each time-step. i have tried many ways, even position = 'append' in the open command doesn't work. i've even tried a test that if the file exists status='old' and 'append' else, create new but i still only have one line


Would anyone have any ideas on how i can get around this problem ?

At the moment this is what i ahve at the begining of my script:

open(file='forces.csv',unit= impusr(1), position='append')
write(impusr(1), * )'TIME-STEP',', FX ',', FY ',', FZ '

open(file='debit.csv',unit= impusr(2), position='append')
write(impusr(2), * )'TIME-STEP',', MASSIN',', MASSOUT',', MASSJIN',', MASSJOUT'


and for example this is what i have when i want to write:

write (impusr(2), 120) ntcabs, massin, massout, massjin, massjout
120 format(2x, I5, 4(", ",g14.7))


best regards,

Sean
Attachments
cs_user_extra_operations-global_efforts.f90
(6.61 KiB) Downloaded 218 times
Post Reply