CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

sinus translation of 2D zone

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 24, 2018, 16:41
Default sinus translation of 2D zone
  #1
New Member
 
Casey
Join Date: Apr 2018
Posts: 4
Rep Power: 8
Fuergrissa is on a distinguished road
I think I have a very simple request, I would like a particular edge in my 2D simulation to oscillate back and forth along the X axis with a specified magnitude and frequency. I made the edge it's own zone and specified rigid body motion and set the adjacent edges to deform.

I'm trying to accomplish this with the 6DOF solver since i've found more examples to look off, but it seems like a UDF specifying the motion or a profile would be easier and more simple then specifying a periodic force and letting the 6DOF solver determine the motion. Any advice for any of these solutions would be very much appreciated. Currently I'm trying to adapt the script shown in the piston and reed valve tutorial (https://youtu.be/BuA6uI2tWuA)

Code:
#include "udf.h"
#include "math.h"

DEFINE_SDOF_PROPERTIES(fin1_6dof, prop, dt, time, dtime)
{
prop[SDOF_MASS] = 0.01;
prop[SDOF_IZZ] = 1e-4;
prop[SDOF_ZERO_TRANS_X] = False;
prop[SDOF_ZERO_TRANS_Y] = TRUE;
prop[SDOF_ZERO_TRANS_Z] = TRUE;
prop[SDOF_ZERO_ROT_X] = TRUE;
prop[SDOF_ZERO_ROT_Y] = TRUE;
prop[SDOF_ZERO_ROT_Z] = TRUE;
prop[SDOF_LOAD_F_X] = .001* sin( 3800 * time );
Message("\n 2d : Updated 6DOF properties %e,Fx,%e\n", prop[SDOF_LOAD_F_X], prop[SDOF_MASS]);
}
If I get this to work I will have to experiment with the values to get the displacement I'm looking for.

I'm not well experienced in fluent and especially in C programming so I greatly appreciate as much detail in your response as you are able to give.
Fuergrissa is offline   Reply With Quote

Old   April 24, 2018, 17:13
Default
  #2
New Member
 
Casey
Join Date: Apr 2018
Posts: 4
Rep Power: 8
Fuergrissa is on a distinguished road
I've also been trying to compile a CG_motion UDF but I must be making a mistake. I'm following this process:

1) Define > User-Defined > Functions > Manage...
2) Select existing library and click "Unload"
3) Define > User-Defined > Functions > Compiled...
4) Click "Add..." if there are other source files required (Fluent reads in a new version of the file regardless of whether or not you delete then add the same source file)
5) Build then Load

with this function

Code:
#include "udf.h"

DEFINE_CG_MOTION(fin_1_motion, dt, vel, omega, time, dtime)
{
real a, w, pi;

pi = 3.1415;

/* define motion variables */
a = 0.2; /* 0.05m movement amplitude */
w = 2 * pi * 3700; /* 2Hz frequency */

/* define object movement law */
vel[0] = 0;
vel[1] = -a * w * sin(w*time); 
vel[2] = 0;
}
When I Build there is a warning in the output:
Quote:
(chdir "H:\2D Vibration\Simulation_files\dp0\FFF\Fluent\libudf") (chdir "win64\2ddp")'nmake' is not recognized as an internal or external command,
operable program or batch file.
And then when I load there is the error:
Quote:
Error: The UDF library you are trying to load (...\dp0\FFF\Fluent\libudf) is not compiled for 2ddp on the current platform (win64).\n\nThe system cannot find the file specified.
\n\n...\dp0\FFF\Fluent\libudf\win64\2ddp\libudf.dl l
Error Object: #f
I was under the impression that the compiling was done when you click Build, am I missing a step?
Fuergrissa is offline   Reply With Quote

Old   April 24, 2018, 18:34
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
error
Code:
(chdir "H:\2D Vibration\Simulation_files\dp0\FFF\Fluent\libudf") (chdir "win64\2ddp")'nmake' is not recognized as an internal or external command,
operable program or batch file.
means you do not have Visual Studio on your computer
you may find detailed information here https://www.cfd-online.com/Wiki/Fluent_FAQ

best regards
AlexanderZ is offline   Reply With Quote

Old   April 24, 2018, 22:06
Default
  #4
New Member
 
Casey
Join Date: Apr 2018
Posts: 4
Rep Power: 8
Fuergrissa is on a distinguished road
I've installed both VS 2017 Express and Community (Im using Ansys 17.1) and both throw errors about missing files when I attempt to "Build" the library in Fluent. First it was stdio.h which isn't included in either VS distribution, so I removed it from the fluent file that was calling it, next is stdarg.h, which is present, and the path variable is declared correctly (I can execute it from the cmd.exe without CD), but fluent still says that it cannot find it. If I remove the reference (line 57 in dll.h) it causes other errors with the syntax so I think it's important.

Don't know what to do at this point ...
Fuergrissa is offline   Reply With Quote

Old   April 25, 2018, 05:00
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
read manual

you should start fluent from console to be able to compile

best regards
AlexanderZ is offline   Reply With Quote

Old   April 25, 2018, 23:24
Default
  #6
New Member
 
Casey
Join Date: Apr 2018
Posts: 4
Rep Power: 8
Fuergrissa is on a distinguished road
Thanks Alexander, with your help I was able to get the udf compiled and loaded correctly.

It doesn't seem to do anything though. I'm out of time so this will likely be my last request for help. perhaps there is something fundamentally wrong with what I want to do.

This is my udf:
Code:
#include "udf.h"

DEFINE_CG_MOTION(fin_1_motion, dt, vel, omega, time, dtime)
{
real a, w, pi;

pi = 3.1415;

/* define motion variables */
a = 0.001; /* 0.001m movement amplitude */
w = 3700; /* 3700 Hz frequency - 1.7ms Period */

/* define object movement law */
vel[0] =  ( a / w )* sin(w*time); 
vel[1] = 0;
vel[2] = 0;
}
It should move the target back and forth along the X-axis with an amplitude of 1mm and period of 1.7ms. I've verified by plotting the position over time in matlab.

When I apply it as the Motion UDF/Profile for Rigid Body Motion in the Dynamic Meshing window and then go to "display Zone Motion" It doesn't seem to do anything.

If you look at the attached picture of my 2D model, the UDF is applied to the horizontal edge at the tip of the fin. The sides of the fin are specified as deforming mesh zones. The Dynamic mesh is set to use smoothing and remeshing and the mesh is made of all triangular elements.

If you have any advice to make it work, it would make a world of difference to me.
Attached Images
File Type: png Capture.PNG (11.3 KB, 10 views)
Fuergrissa is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Commercial meshers] Mesh conversion problem (fluent3DMeshToFoam) Aadhavan OpenFOAM Meshing & Mesh Conversion 2 March 8, 2018 01:47
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 09:28
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 10:52
Problem in running ICEM grid in Openfoam Tarak OpenFOAM 6 September 9, 2011 17:51
Problem in IMPORT of ICEM input file in FLUENT csvirume FLUENT 2 September 9, 2009 01:08


All times are GMT -4. The time now is 12:09.