|
[Sponsors] |
July 19, 2012, 07:15 |
Error: Cycle detected in field function
|
#1 |
New Member
Rachit Prasad
Join Date: Jun 2011
Location: Blacksburg, Virginia
Posts: 29
Rep Power: 15 |
Hi everyone,
I am carrying out a CFD analysis of a wind turbine. I want the turbine blades to rotating. The idea is to define a circular region around the blade which will be rotating at a certain angular velocity and will exchange data with the surrounding environment through a sliding mesh. Now, what I want is that angular velocity of the circular region be defined as: w = 2.3559, for t <= 0.015s w(t) = w(t - 1) + (Torque / Moment of Inertia)*TimeStep, for t > 0.015s where Torque is the moment on the turbine blades. for this i had defined a field function UserFieldFunction_1 defined as: ($Time <= 0.015) ? 2.3559 : $UserFieldFunction_1 + (($Torque/1.308)*0.005) (moment of inertia is 1.308 kgm^2 and the time step is 0.005s) however, following this i get the error message: "Warning: 1 cycle detected in function Turbine anglular velocity (UserFieldFunction_1)" can anyone what am i doing wrong and how it can be rectified? i think its because of referencing the same field function in code, but then how else could such a function be defined? Thanks in advance, Regards, Rachit |
|
July 19, 2012, 11:19 |
|
#2 |
Member
Ryan Coe
Join Date: Jun 2010
Location: Albuquerque, NM
Posts: 98
Rep Power: 16 |
If understand the logic that you're trying to use correctly, couldn't you use:
($Time <= 0.015) ? 2.3559 : 2.3559 + (($Torque/1.308)*0.005) In your current implementation, when t > 0.015 the algorithm can never find a value of $UserFieldFunction_1 to use in the 2nd half of the statement. Hope this helps, Ryan
__________________
Ryan |
|
July 24, 2012, 05:48 |
|
#3 |
New Member
Rachit Prasad
Join Date: Jun 2011
Location: Blacksburg, Virginia
Posts: 29
Rep Power: 15 |
Hi Ryan,
Thanks for replying. I shall be more clear of what I wish to accomplish, and correct me if I am wrong. I want the turbine to rotate with an angular velocity which is directly obtained from the equation: Torque = I*alpha, where I is moment of inertia and alpha is the angular acceleration that gives, alpha = Torque/I now applying, euler's first order integration, we have [(w(t) - w(t - 1))/delta T] = Torque/I that gives me the relation mentioned in the previous post: w(t) = w(t -1) + (Torque/I)*TimeStep that is why I have to use the angular velocity from the previous time step. I understand what error I am getting, any idea how I can bypass it? Regards, Rachit |
|
July 24, 2012, 09:26 |
|
#4 |
Member
Ryan Coe
Join Date: Jun 2010
Location: Albuquerque, NM
Posts: 98
Rep Power: 16 |
I see... Sorry I misunderstood you before. I think that the easiest way to do this within Star-CCM+ (that is without using macros), would be to assign the value of w(t) to a table value, and then reference that value as well. I've never done this myself, but I'm pretty sure its possible (there's a section describing this sort of thing in the Help manual: "Working With Table Values Through Field Functions").
Alternatively, if you want to stay away from tables and just use an algorithm, you could write a java macro containing a for loop which creates and references the array w(t). The macro can then reassign the new w(t) value to a field function at every time step. Ryan
__________________
Ryan |
|
July 27, 2012, 05:20 |
|
#5 |
New Member
Rachit Prasad
Join Date: Jun 2011
Location: Blacksburg, Virginia
Posts: 29
Rep Power: 15 |
Dear Ryan,
I have been trying to figure out how to write a macro for this situation only to find myself extremely confused . This is my first macro so correct me if my approach is wrong. What I have been thinking is that I could record a macro in which I will change the field function definition as: [(2.3559 + (($Torque/1.308)*0.005))], following which I will run the simulation for 1 time step. On recording this macro, I will change its java script by defining a variable temp which initially I will set it as 2.3559 and change the user field function definition as: [(temp + (($Torque/1.308)*0.005))], however, the value of temp has to be updated after every time step as temp = UserFieldFunction_1. I can then run the simulation for as many number of time steps by modifying simulation_0.getSimulationIterator().run(). Could you tell if this is possible or not? I have recorded the macro, but have little idea how to modify the java script. How can i update the term temp after every time step? Are there any guides available for scripting in Star CCM+? (There are very less examples in User Guide) |
|
July 27, 2012, 12:19 |
|
#6 |
Member
Ryan Coe
Join Date: Jun 2010
Location: Albuquerque, NM
Posts: 98
Rep Power: 16 |
If you've done any programming, editing and writing macros shouldn't be too hard. I would definitely suggest using an IDE like Netbeans or Eclipse. If you point theseIDEs to Star-CCM+'s packages, they can be really helpful.
There are 2 tutorials on Automation in the Help Manual that should give you a basic understanding of how things work. I know this can be a bit daunting at first, but its worth your time. Ryan
__________________
Ryan |
|
July 28, 2012, 09:36 |
|
#7 |
Senior Member
Join Date: Oct 2009
Location: Germany
Posts: 636
Rep Power: 22 |
You don't even need to update the field function, you can try it with the attached macro. I couldn't upload a java file, so I renamed it to txt. Just change the file ending to java, and you can execute it in Star-CCM+.
I haven't tested the macro, but just try it and let us know when it doesn't work.
__________________
We do three types of jobs here: GOOD, FAST AND CHEAP You may choose any two! |
|
July 30, 2012, 07:42 |
|
#8 |
New Member
Rachit Prasad
Join Date: Jun 2011
Location: Blacksburg, Virginia
Posts: 29
Rep Power: 15 |
@abdul099
Thanks a lot! Your macro works just fine. I am getting the expected results. Regards, Rachit |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
problems after decomposing for running | alessio.nz | OpenFOAM | 7 | March 5, 2021 05:49 |
Field Function Question. Need help writing it :((( | kj878 | Siemens | 1 | February 14, 2012 19:30 |
LiencubiclowRemodel | nzy102 | OpenFOAM Bugs | 14 | January 10, 2012 09:53 |
Force Report help~ or maybe Custom Field Function | sailor | FLUENT | 0 | April 13, 2011 04:45 |
time step size in Custom Field Function | Tong | FLUENT | 0 | May 2, 2008 16:51 |