Could anyone help me write UDF for time dependent temperature in BC
Hey all, I need some help on writing UDF for Inlet BC. The inlet temp changes in time from 300K to 800K and back to 300K.
Problem: Step1. 100 s temp stays 300K Step 2. 100s to 700s Temp grows linearly to 800 K Step 3. 700s to 1600s Temp remains 800K Step 4. 1600s to 1900s Temp is 300K Hope anyone can help me! :) 
Quote:
t=CURRENT_TIME; if t<100; Temp=300; if t<700; Temp=300+Gradient*(t100); if t>700; Temp=800; if t>1600 AND t<1900; Temp=300; This syntax will be wrong but this is the idea you need! Obviously the gradient is the slope of your linear increase. 
Thank you for your ideas.
I wrote it like this (I simplified it and changed times and temps a bit...): #include "udf.h" DEFINE_PROFILE(temperature_profile,thread,position ) { face_t f; begin_f_loop(f,thread) { real t = RP_Get_Real("flowtime"); if ( t < 600.0 ) F_PROFILE(f,thread,position) = 300.0+1.16666667 * t; else if ( t < 1800.0 ) F_PROFILE(f,thread,position) = 1000.0; else F_PROFILE(f,thread,position) = 300.0; } end_f_loop(f,thread) } https://lh3.googleusercontent.com/p...acemonitor.jpg This is a pic from the pipes inside surface monitor. Time step is 120, step 20 s and 20 iterations per step. Itīs working but until the end when it does the jump up again. Can please anyone help me to fine the problem? 
Did you check that the correct temperature boundary condition was being applied? Do the contours of temperature at the boundary look ok?
Are you sure that the solution is converging? 
Quote:
Try putting another if statement if t>1800 temp=300 Do you want it to be constant afterwards or do you want thist profile to repeat? 
=> Daniel Tanner the temperature change is put on to inlet boundary witch is were I need it. The temp at the wall doesnīt look that grate in the end.
=> Iīm gonna try the other if statement tomorrow. In the first solution it dosnīt have to repeat but in the later solution it should stay 300 K for some time and then repeat again. Thank you for your help! 
Tested it out and the temperature distripution looks nice through out the flow time and itīs the heattransfer results come back as I expected. But there are still some problems.
https://lh6.googleusercontent.com/B...20history1.jpg https://lh6.googleusercontent.com/h...dualsplot1.jpg reversed flow in 377 faces on outflow 12. turbulent viscosity limited to viscosity ratio of 1.000000e+05 in 62286 cells Should I just ignore it or what should I do? 
Quote:
Also your solution doesn't seem to be converged, how many iterations per time step are you using and what is your timestep? Is your Reynolds number what you would expect it to be, roughly? EDIT: OK I've just seen that you've plotted 2500+ iterations so of course it doesn't look converged, ignore that comment. 
It looks like you have one iteration per time step and have a time step of one second, is this correct? I think you need to reconsider this. How have you calculated your time step?

I used Time step size: 20 steps: 120 and iterations 20. I canīt use pressure outlet because I donīt know the temp there. How can I know when the solution is converged?

I made some changes in the mesh and in the velocity Kepsilon model and run the calculation again with 100 iterations per time step. At first everything was running smoothly but as the temp rose near 1000 K the solution didnīt want to converge. And the velocity limitation and back flow warnings are still there...

I don't think this is a good way to do it. Ideally there should be less than 20 iterations per time step and it should achieve convergence (not just stop because it reaches 20).
Try reducing the time step such that you get this. It might require some playing around. You could base this on the maximum velocity and the mesh size as an estimate. Try to get udt/dx < 1 as an estimate for your timestep t (u is the velocity and dx the mesh spacing  the CFL condition). 
I changed 1s 2400 steps 20 iterations and one other way but the solution doesenīt reach convergence. I checked the out flow pattern and that is jumping as well. There is some problem with the flow that shouldnīt be there... I tried with changing the flow to laminar, changing the outflow to pressure outlet, changed Kepsilon model from standard to releasable, played around with the mesh but same thing happens. I donīt know what do do next. I have heard that itīs some times difficult to get conjugate heat transfer to reach convergence.
All though the temp distripution is looking oky and it seems to do in the temp wise what I expect. Just out of ideas... 
Answer to your PM about convergence
1 Attachment(s)
Quote:
Hi, sorry for late reply I've been very busy. When you run a CFD simulation, you are trying to iteratively solve a set of equations. As you know, when you start a CFD simulation, you initialise the solution to a guess (eg. flow velocity = 0 everywhere). After each iteration, you (hopefully) have a better guess of the flow you are trying to solve. Say we are trying to iteratively solve the equation x+1=5 Let our first guess be x=0.. 0+1=1 The residual can be though of as the difference between the guessed solution and the real one, so here the absolute residual is 51= 4. We then use our last result as the new guess: 1+1=2 , residual is 52=3 iterating again 1+2=3, residual is 53=2 iterate again.. 1+3=4, residual is 54=1 1+4=5, residual is 55=0 So the residual has gone 3,2,1,0. When the residual is zero, our solution is fully converged. The exact residual value that you seen in Fluent is a bit more complicated than this, but you get the idea. We want the residual to be as low as possible. When it is as low as it can get, we say the solution is converged. Sometimes though, this doesn't happen. Sometimes the residual goes to infinity (divergence), or stays the same (nonconverged), or goes up and down about a fixed value (oscillating convergence). You can see an example in the attachment. The top graph shows convergence for a transient solution like your problem. For each timestep, the solution has to converge because the flow properties (hence the equations to be solved) change with each timestep. Ideally you want to be converged in under 20 iterations per timestep, this is done by gradually reducing the timestep. Sometimes, however, you can get OK results by waiting longer for convergence, and using a bigger timestep (=faster simulation). Hope this helps, let me know if you have any more questions. 
Quote:

All times are GMT 4. The time now is 13:46. 