|
[Sponsors] |
2D rotating detonation simulation - UDF inlet BC |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 23, 2020, 02:57 |
2D rotating detonation simulation - UDF inlet BC
|
#1 |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
Hi guys,
This is quite urgent! I am doing 2D rotating detonation engine (RDE) simulation in ANSYS Fluent. For pressure inlet boundary condition, there are three possible cases: 1. Pi > Po, where Pi is the pressure inside the domain immediately at the inlet and Po is the total inflow pressure. In this case the pressure inside the RDE at this point is very high and blocks inflow of new mixture through the inlet face. The inlet boundary acts as a wall. 2. Pcr < Pi < Po, where Pcr is the critical pressure. In this case the inlet is not chocked and new mixture flows into the RDE according to: mass flow rate = the integral of (rho*u*dA). 3. Pi < Pcr, in this case the pressure inside the domain is low. The inlet at this point is choked, so maximum flow rate of fuel is flowing into the domain. Pcr is calculated from isentropic relation. My UDF (mass flow rate inlet BC) compiles successfully which means the code is grammatically correct. When I tried to initialise the solution, the following errors appeared. Node 0: Process 3524: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 1: Process 10032: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 2: Process 11508: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 3: Process 12336: Received signal SIGSEGV. ================================================== ============================ 999999: mpt_accept: error: accept failed: No error 999999: mpt_accept: error: accept failed: No error 999999: mpt_accept: error: accept failed: No error 999999: mpt_accept: error: accept failed: No error 999999: mpt_accept: error: accept failed: No error MPI Application rank 0 exited before MPI_Finalize() with status 2 The fl process could not be started. I tried standalone mode of Fluent, it also didn't work.... I think this may because the logic of the code, or this UDF is not suitable for Fluent. My code is the following: #include "udf.h" DEFINE_PROFILE(inlet_mf,th,i) { face_t f; cell_t c; Domain *d = Get_Domain(1); Thread *t = Lookup_Thread(d,5); real pw; real po; real pcr; real To; real gamma; real v; real vmax; real R; real rho1; real rho2; real area; real A[ND_ND]; R = 368.9; // J/kg k gamma = 1.29; po = 1013250; pcr = po * pow( (2/(gamma+1)), (gamma/(gamma-1)) ); To = 300; vmax = sqrt( (2*gamma/(gamma+1)) *R*To ); begin_f_loop(f,th) { pw = F_P(f,th); //pressure on one face F_AREA(A,f,th); area = NV_MAG(A); // Find area of one face if(pw >= po) { F_PROFILE(f,th,i) = 0.0000001; } else if(pw > pcr && pw < po) { v = sqrt( (2*gamma/(gamma-1)) *R*To * (1 - pow(pw/po, (gamma-1)/gamma)) ); rho1 = F_R(f,th); F_PROFILE(f,th,i) = rho1*v*area; } else if(pw <= pcr) { rho2 = F_R(f,th); F_PROFILE(f,th,i) = rho2*vmax*area; } } end_f_loop(f,th) } Could anyone give me some advises and help? Thanks very much! |
|
July 23, 2020, 03:22 |
|
#2 |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
For someone may get confusion. I'm adjusting mass flow inlet.
|
|
July 23, 2020, 03:39 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
code seems to be good,
the only thing you can do, which is not mandatory, you can add math library Code:
#include "math.h" when did you get this error? on the first iteration? you may check, if the problem in UDF or not, using very simple profile Code:
#include "udf.h" DEFINE_PROFILE(inlet_mf,th,i) { face_t f; begin_f_loop(f,th) { F_PROFILE(f,th,i) = 0.0000001; } end_f_loop(f,th) }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
July 23, 2020, 03:57 |
|
#4 | |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
Quote:
Thanks for the reply! The error appears when I initialise the domain. I wasn't able to run the simulation. I tried to add ''#include math.h", it still didn't work.. Regards |
||
July 23, 2020, 04:13 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
did you try simplified code?
may be the problem with your code is that you are using pressure and density. to initialize domain fluent applies boundary conditions In other words there is no pressure and density yet what you can try, initialize your case with constant mass-flow value and hook profile after that
__________________
best regards ****************************** press LIKE if this message was helpful |
|
July 23, 2020, 04:22 |
|
#6 | |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
Quote:
That sounds a good idea, I'll get back to you once I try that! Thanks |
||
July 24, 2020, 01:15 |
|
#7 | |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
Quote:
I initialize the case with constant mass-flow inlet value and ambient pressure value. Once I tried to hook the UDF on mass flow BC, the same error appeared. In my code, I used F_R, do I need to get the density value from a cell rather than a face? Regards |
||
July 24, 2020, 02:33 |
|
#8 | |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
Quote:
|
||
July 24, 2020, 03:57 |
|
#9 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
I think, that you need values from surface, not from the cell
you can add condition to check, if the face belongs to boundary or not if (BOUNDARY_FACE_THREAD_P(t)) Code:
#include "udf.h" DEFINE_PROFILE(inlet_mf,th,i) { face_t f; cell_t c; Domain *d = Get_Domain(1); Thread *t = Lookup_Thread(d,5); real pw; real po; real pcr; real To; real gamma; real v; real vmax; real R; real rho1; real rho2; real area; real A[ND_ND]; R = 368.9; // J/kg k gamma = 1.29; po = 1013250; pcr = po * pow( (2/(gamma+1)), (gamma/(gamma-1)) ); To = 300; vmax = sqrt( (2*gamma/(gamma+1)) *R*To ); begin_f_loop(f,th) { F_AREA(A,f,th); area = NV_MAG(A); // Find area of one face if (BOUNDARY_FACE_THREAD_P(th)) { pw = F_P(f,th); //pressure on one face if(pw >= po) { F_PROFILE(f,th,i) = 0.0000001; } else if(pw > pcr && pw < po) { v = sqrt( (2*gamma/(gamma-1)) *R*To * (1 - pow(pw/po, (gamma-1)/gamma)) ); rho1 = F_R(f,th); F_PROFILE(f,th,i) = rho1*v*area; } else if(pw <= pcr) { rho2 = F_R(f,th); F_PROFILE(f,th,i) = rho2*vmax*area; } } } end_f_loop(f,th) }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
July 27, 2020, 03:27 |
|
#10 | |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
Quote:
I modified the UDF to hook velocity inlet BC, it works fine with no chemistry. The inlet velocity could be adjusted according to wall pressure. But once I import chemistry (hydrogen air mechanism with 23 reactions and 9 species), the same error appeared. Is my UDF able to work to import chemkin mechanism? I'll attach my code to the next post. Regards, |
||
July 27, 2020, 03:28 |
|
#11 |
New Member
Tianxu Yin
Join Date: May 2020
Posts: 24
Rep Power: 6 |
The up-to-date velocity inlet UDF:
#include "udf.h" DEFINE_PROFILE(inlet_velocity,th,i) { face_t f; cell_t c; Domain *d = Get_Domain(1); Thread *t = Lookup_Thread(d,5); real po; real pcr; real To; real gamma; real R; real p_cur; po = 1013250; // stagnation pressure gamma = 1.29; pcr = po * pow(2/(gamma + 1), gamma/(gamma-1)); // critical pressure To = 300; // stagnation temperature R = 368.9; // J/kg k begin_f_loop(f,th) //to find pi, pressure inside the domain immediately at the inlet { p_cur = F_P(f,th); //pressure on one face if(p_cur >= po) F_PROFILE(f,th,i) = 0.0000001; else if(p_cur <= po && p_cur > pcr) F_PROFILE(f,th,i) = sqrt( 2*gamma/(gamma-1) *R*To * (1 - pow(p_cur/po, gamma-1/gamma)) ); else if(p_cur <= pcr) F_PROFILE(f,th,i) = sqrt(2*gamma/(gamma+1) *R*To); } end_f_loop(f,th) } DEFINE_PROFILE(inlet_temperature,th,i) { face_t f; Domain *d = Get_Domain(1); Thread *t = Lookup_Thread(d,5); real To; real p_cur; real po; real gamma; po = 1013250; // stagnation pressure To = 300; // stagnation temperature gamma = 1.29; begin_f_loop(f,th) //to find pi, pressure inside the domain immediately at the inlet { p_cur = F_P(f,th); //pressure on one face F_PROFILE(f,th,i) = To * pow(p_cur/po,(gamma - 1)/gamma); // Temperature } end_f_loop(f,th) } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Rotating motion simulation in fluent | yusuf.5ayat | ANSYS | 0 | January 10, 2017 07:18 |
Udf to measure radius of inlet as it changes - FSI simulation | DamR | Fluent UDF and Scheme Programming | 0 | December 28, 2016 03:54 |
How to set unsteady turbulent inlet velocity using the result of another simulation? | John-Lee | FLUENT | 2 | December 27, 2016 18:36 |
Doubts in injection mould simulation (inlet conditions, temperature...) | jpina | FLUENT | 7 | October 3, 2016 09:14 |
UDF: Change boundary condition. Velocity inlet to pressure inlet at time "t" | jpina | FLUENT | 10 | April 11, 2015 15:19 |