Struggling with if-else statement in UDF
Hi I am writing for udf pulsed laser source. But I got problem with changing the velocity(it needs to be 0 when heating and become 1 when waiting time). So I discrete my code understand that origin of problem. So I seperated if statement for source and velocity. If statement for source is working very well. But if statement for vel has a problem. The "else" part is working when condition met but for if part it uses the predefined(0.0) value.
Code:
#include "udf.h" P.S; I notice while writing this post, I can use initial value like if condition value. But still I am wandering where is my mistake |
vel = 0.1 for time 0 -> 0.01
vel = 0.99 after that code is correct your statements for sources are identical, so you don't really need if statement there |
Ah I understand what you mean and thx for help. sorry I was made a lot of change and the second part will be zero.
And also I solved half of my problem. Vel is changing but x_pos still become 0 because of calculation. So I made changes and improvements however while it compiled without problem "x_pos = x_pos + displacement;" line didn't work properly; Code:
#include "udf.h" |
Code:
static real x_pos = 0.0; |
Because of the following part of code, it is incremental and need to change every timestep.
Code:
vel = 0.0; I solved now with execute at end macro. I get that hint from your answers in another problem thread. Thanks AlexanderZ:D:D |
All times are GMT -4. The time now is 03:33. |