|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
hello ;
i need help , i am simulating a rotating airfoil and i wrote a udf for the motion by define_zone_motion so i define psi (azimuth angle ) psi =omega*(time) and omega is the rotational speed. but i want to activate the source term only in 90° to 120° azimuthal position appreciate any help please thanks Last edited by pitch; February 26, 2020 at 12:03. |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
|
Your description is little unclear. Is there issue with zone motion UDF or with source UDF?
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
Thank you
For the source term how to active with azimth position because to use in define_source the same angle defined in zone_motion it sows error that undeclared variable Last edited by pitch; February 18, 2020 at 10:07. |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
|
So, all you need is to know the azimuthal position within DEFINE_SOURCE. If the rotational displacement or speed is user parameter then you can do the same calculation in DEFINE_SOURCE and apply the source if the position is within the required bounds.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#5 |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
dear vinerm
i am using this DEFINE_ZONE_MOTION(blade,omega,axis,origin,velocit y,time,dtime) { psi=omegac*(time); return; } DEFINE_SOURCE(Source1, c, t, dS, eqn) { real Source; real time = RP_Get_Real("flow-time"); real psi=omegac*(time); if (psi>= 90*M_PI/180 && psi <= 100*M_PI/180 ) { Source=C_UDMI(c,t,F); ****i saved C_UDMI(c,t,F)***** dS[eqn]=0; } else { Source=0.0; dS[eqn]=0; } return Sourcex; } Last edited by pitch; February 26, 2020 at 12:04. |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
|
Hi
If this is the complete UDF then I have doubts that it works. Your SOURCE UDF is alright. It should work perfectly, except for two issues. What is omegac? It is not defined anywhere. Furthermore, what is F, the last argument of UDM? The last argument should correspond to the number of the UDM. If you have only one UDM in your case, then it should be 0 and not F. Of course, you can call it F provided you declare int F = 0; in your code. ZONE_MOTION is supposed to provide velocities and not position. If omega is fixed or changing with time, you do not need this UDF. For fixed omega, just provide the number in the cell zone conditions. If it is changing with time, then you can use this UDF or profile. But in that case, UDF requires modification. psi is not defined anywhere nor is omegac. As far as time is concerned, it is not a property of any macro. This is available to all macros. You can directly use CURRENT_TIME instead of using RP macro. CURRENT_TIME is a C based variable defined in Fluent and is equal to the current simulation time.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#7 | |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#8 |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
Psi is defined
Last edited by pitch; February 19, 2020 at 13:16. |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Senior Member
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia, Sydney
Posts: 416
Rep Power: 15 ![]() |
omegac is not defined in the code; can you please add it?
|
|
![]() |
![]() |
![]() |
![]() |
#10 |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
Thank you
Its defined befor define zone motion its just not shown Real omegac =500rpm Last edited by pitch; February 26, 2020 at 12:04. |
|
![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia, Sydney
Posts: 416
Rep Power: 15 ![]() |
Can you please post the complete code?
|
|
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
|
From any of your posts, it is not clear what the issue is. Did you try the code? In my view, if you make the changes recommended by Svetlana and me, it would work alright. Let us know if you face any issue and also post the issue that you face.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#13 | |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
Quote:
but stil the Sourcex=0 so it's not changing with time Last edited by pitch; February 19, 2020 at 13:01. |
||
![]() |
![]() |
![]() |
![]() |
#14 |
Senior Member
|
Are you able to run a simulation with this code? Fluent would give error as soon as you compile it or interpret it. It should be C_UDMI(c, t, 1), assuming you have at least 2 UDMs in your simulation. If there is only one UDM, then it should be C_UDMI(c, t, 0). You cannot use F as an argument. If you wish to multiply UDM value with F, it has to be C_UDMI(c,t,0) * F or C_UDMI(c,t,1) * F. And C_UDMI should have a value that is different from 0.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#15 |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
[QUOTE=vinerm;758737]Are you able to run a simulation with this code? Fluent would give error as soon as you compile it or interpret it. It should be C_UDMI(c, t, 1), assuming you have at least 2 UDMs in your simulation. If there is only one UDM, then it should be C_UDMI(c, t, 0). You cannot use F as an argument. If you wish to multiply UDM value with F, it has to be C_UDMI(c,t,0) * F or C_UDMI(c,t,1) * F. And C_UDMI should have a value that is different from 0.[/QUOTE
DEFINE_SOURCE(X_Source1, c, t, dS, eqn) { real Sourcex; real time= CURRENT_TIME; if (0.0 <= CURRENT_TIME < 0.02 ) { Sourcex=C_UDMI(c,t,Fx1); dS[eqn]=0; } else if (0.02<= CURRENT_TIME < 0.03 ) { Sourcex=0.0; dS[eqn]=0; } return Sourcex; } please for all variables are defined in the code just too lange to show so the problem is in time and after i compile it no error Last edited by pitch; February 19, 2020 at 16:22. |
|
![]() |
![]() |
![]() |
![]() |
#16 |
Senior Member
|
Alright, I am assuming that the indices that you use for UDMs are defined, either as integers or enum. And they have to be, otherwise your code would not have worked. There are also a few commands that are not of any use, such as, extraction of Zone ID. First thing you can check is the time of your case. Use the following command in TUI to see whether the time is between 0 and 0.02 or not.
(rpgetvar 'flow-time) Also, at least for the debugging, use a smaller time-step, such as, 0.002. If the time is within the bounds where source should have some value other than 0 then do the following 1. Write a profile file as follows, using any text editor. ((sourcex transient 3 0) (time 0 0.02 0.03 ) (src 900.0 1000.0 0.0 )) 2. Read this into Fluent and hook in place of Source UDF. 3. Run the case for one time-step and see if you observe the effects of the source.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#17 |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
IT SHOWS > (rpgetvar 'flow-time)
invalid command [(rpgetvar] **and i included the brackets * |
|
![]() |
![]() |
![]() |
![]() |
#18 |
Senior Member
|
Did you do a copy and paste from the post? Then it will give this error. Yes, you have to use parentheses but you need to type the command.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#19 | |
New Member
iyad
Join Date: Nov 2019
Posts: 21
Rep Power: 7 ![]() |
Quote:
DEFINE_SOURCE(X_Source1, c, t, dS, eqn) { real Sourcex; real time= CURRENT_TIME; if (0.0 <= CURRENT_TIME < 0.001 ) { Sourcex=C_UDMI(c,t,Fx1); dS[eqn]=0; } else if (0.001 <= CURRENT_TIME < 0.003 ) { Sourcex=0.0; dS[eqn]=0; } return Sourcex; } i get this > (rpgetvar 'flow-time) 0.001 |
||
![]() |
![]() |
![]() |
![]() |
#20 |
Senior Member
|
What I meant is that you keep your code as it but use a smaller time-step in Run Simulation panel. As far as using profile is concerned, do not use the UDF. Use only the profile and check if it works.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] swak4foam for OpenFOAM 4.0 | mnikku | OpenFOAM Community Contributions | 80 | May 17, 2022 09:06 |
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 | ordinary | OpenFOAM Installation | 19 | September 3, 2019 19:13 |
using value of surface integral in source term UDF | morihangi | Fluent UDF and Scheme Programming | 0 | March 23, 2019 04:59 |
SparceImage v1.7.x Issue on MAC OS X | rcarmi | OpenFOAM Installation | 4 | August 14, 2014 07:42 |
Problem compiling a custom Lagrangian library | brbbhatti | OpenFOAM Programming & Development | 2 | July 7, 2014 12:32 |