|
[Sponsors] |
March 9, 2015, 19:03 |
rpm as function of time in SRF model ?
|
#1 |
New Member
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 14 |
Hi,
I've added SRF functionality to porousInterFoam v.2.3.1 to model conditions in a vial of fluid (a suspension) in a spinning centrifuge. It works , but we want the centrifuge to slowly come up to full speed. I'd like to use a table to specify a time-dependent rpm in the SRFProperties file, but the code is expecting a scalar. I see that swirlFlowRateInletVelocityFvPatchVectorField.C, for example, can update omega with rpm specified as table. How can I implement this in my SRFPorousInterFoam solver? Essentially, how can I get updated values each time step of rpm and then FCoriolis and FCentrifugal? I'm not so good at C++, but pretty good at following examples. Can you help me? Thanks! -Ron. |
|
March 10, 2015, 03:02 |
|
#2 |
Senior Member
|
Hi,
Straightforward implementation can be something like: you take src/finiteVolume/cfdTools/general/SRF/SRFModel/rpm model as a base and create varyingRpm model where you change this Code:
class rpm : public SRFModel { //- Revolutions per minute scalar rpm_; ... } Code:
class varyingRpm : public SRFModel { //- Revolutions per minute autoPtr<DataEntry<scalar> > rpm_; ... } You can find examples of DataEntry constructor and data interpolation in swirlFlowRateInletVelocityFvPatchVectorField.C. |
|
March 10, 2015, 18:43 |
|
#3 | |
New Member
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 14 |
Thanks, alexeym!
Now my faded C++ skills are showing. I've modified rpm.H and rpm.C as varyingRpm.H and varyingRpm.C (see attached). It compiles with error since the constructor now needs a dictionary. Where do I override SRFModel's omega, Fcoriolis, Fcentrifugal, velocity, U methods? In varyingRpm.C or in a modified SRFModel.C ? If you can give me one override example, I can probably replicate for the rest. I would not have gotten this far without your help! Thanks, -Ron. Quote:
|
||
March 11, 2015, 09:28 |
|
#4 |
Senior Member
|
Hi,
I have looked more closely at SRFModel and have two news. About your implementation: 1. You can't change number of constructor arguments in children classes. So your constructor should look like Code:
varyingRpm(const volVectorField& U); Code:
Foam::SRF::varyingRpm::varyingRpm ( const volVectorField& U ) : SRFModel(typeName, U), rpm_(DataEntry<scalar>::New("varyingRpm", SRFModelCoeffs_)) { ... } |
|
March 12, 2015, 03:40 |
|
#5 | |
New Member
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 14 |
Thanks again, alexeym!
I've corrected varyingRpm as you suggested and no compiler errors. I'm okay with modifying SRFModel and it seems I should be able to use its omega() function to obtain the new omega value from varyingRpm's read() function. I haven't programmed C++ for 20 years, so I'm puzzled how SRFModel obtains omega_.value from varyingRpm. Can you help me with that? Since I can call omega() when calculating FCoriolis and FCentrifugal, it seems it could work if omega() has gotten the new value from varyingRpm::read() Thanks for all your help, -Ron. Quote:
|
||
March 14, 2015, 12:47 |
|
#6 |
Senior Member
|
Hi,
You are right, read method of SRFModel can be overridden and using this method it is possible to change value of omega. But this method is called only when SRFProperties dictionary was modified. While it is necessary to modify omega on every time step. My idea was to create mSRFModel class which has virtual method (i.e. that can be overridden in children). SRF(P|S)impleFoam solvers call Su method every time they construct UrelEqn, so this will be our candidate for virtualization. Problem is this approach is necessity to: - correct SRFModel - correct derived patch fields - correct solvers You can find POC implementation of these corrections with modified tutorial case attached to the message. To build modified versions of library and solvers, you untar mSRF.tar.gz archive, run wmake in src/finiteVolume folder (this will create mSRF.so library), and finally run wmake in applications/solvers/incompressible/mSRF(P|S)impleFoam folders (these operations will create two solver mSRFPimpleFoam and mSRFSimpleFoam). Then you can try to run rotor2D test case. Unfortunately on my laptop the case diverged due to turbulence model. I have added RPM value output and it seems to be growing according to the interpolation table. |
|
May 6, 2017, 16:59 |
Euler force
|
#7 |
New Member
Join Date: Jun 2009
Posts: 22
Rep Power: 17 |
Hi,
Google led me to this old thread... and I have one small comment that may be useful for anyone attempting something similar. In a rotating frame of reference with varying rotation rate a third fictitious force appear (apart from centrifugal and Coriolis), the so called Euler force, Another comment is that it doesn't make sense to me to have a non transient Simple solver with time varying rotation rate. |
|
January 7, 2021, 17:50 |
Error while compiling solver
|
#8 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Hi,
I came across this thread while searching for a way to provide variable rpm (rpm as function of time). I found this thread extremely helpful and used it as a reference for creating "varSRF" like "mSRF". One thing I did differently is that instead of compiling it as a separate library, i compiled it as a part of finiteVolume library. This worked well and there were no errors. However, when I made all the required changes to my solver and compiled it, it get the following error: OpenFOAM-v1806/build/linux64GccDPInt32Opt/applications/solvers/grooveAsperityFoam_generic_reversed_SRF_var/grooveAsperityFoam_generic_reversed_SRF_var.o: In function `main': grooveAsperityFoam_generic_reversed_SRF_var.C.te xt.startup+0x1690): undefined reference to `Foam::varSRF::varSRFModel::New(Foam::GeometricFie ld<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&)' grooveAsperityFoam_generic_reversed_SRF_var.C.te xt.startup+0x39e1): undefined reference to `Foam::varSRF::varSRFModel::New(Foam::GeometricFie ld<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&)' collect2: error: ld returned 1 exit status make: *** [/home/hharia/OpenFOAM/OpenFOAM-v1806/platforms/linux64GccDPInt32Opt/bin/grooveAsperityFoam_generic_reversed_SRF_var] Error 1 I have been struggling with this error related to autoPtr and suspect that this is associated with the additional lines in the createFields.H. I have read hundreds of posts on this error and tried various things to resolve it. However, I have not been successful and currently stuck. Any help will be highly appreciated. Thanks in advance! Additional Information: OF version: v1806 Solver: It is a user defined solver built using PimpleFOAM as a reference (the solver has been tested with constant SRF speed and works. It crashes with this new modification for rpm as a function of time) |
|
January 12, 2021, 10:43 |
|
#9 |
Senior Member
|
@user_HH
As you did not post any code, let's try to deduce, what you have done wrong (also, it is better not to touch finiteVolume library, simply link you new model with your solver, if you do not want to deal with a separate library). Since it complains about Code:
Foam::varSRF::varSRFModel::New Next question is: how do you instantiate you SRF model? |
|
January 12, 2021, 11:16 |
|
#10 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Alexey,
Thank you so much for the help. You are correct about the varSRFNew.C I had made all the required changes that you recommended in the attached file. But what I missed was to add the varSRFNew.C to Make/files. So there was no link created to it and when I called it in the solver, it showed compilation error. After studying the log file while compiling finiteVolume, i observed that the varSRFNew.C file was missing. Now, there are no errors after adding this link. One question regarding your comment: "it is better not to touch finiteVolume library, simply link you new model with your solver, if you do not want to deal with a separate library" I tried keeping it separate but couldn't figure out a way to do it or have a separate Make folder dedicated to it. Can you help describe the steps to treat it independently? As in src/finiteVolume there already is a Make folder. As i did not know how to do it, it added it to the finiteVolume Make/files. But it is time consuming to compile the contents of entire folder for a small change made in SRF. Sorry i am new to creating my own utilities or BCs and do not understand the whole process yet. Best, Hiral |
|
January 13, 2021, 04:53 |
|
#11 |
Senior Member
|
@user_HH
I am not sure if I get you right, but you just put varSRF files into your solver folder, add these files to your solver's Make/files and that's it. varSRF is compiled and liked to your solver, so your solver (and only your solver) knows about this new SRF model. Separate libraries are necessary if you plan to share your model with others, or you plan someone else to work on it (so varSRF model is modified and compiled separately from the solver). If you intend to use this model alone, just make it part of your solver for simplicity. |
|
January 13, 2021, 10:26 |
|
#12 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Alexey,
That's a great idea. I never thought that was possible. I only need to use it with my specific solver currently. So I can add it to my solver make/files. I will try it out. Thank you so much. Best, Hiral |
|
January 18, 2021, 12:38 |
Though the new varSRF works, it only reads the value of rpm at t=0
|
#13 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Alexey,
I noticed an issue with the variable SRF rpm utility. Though it compiles and runs, when I printed the value of omega_ calculated from rpm in the varSRF module, it shows that the value of omega_ is not updated after first time step. I tried a few things but they did not work to achieve variable rpm read at each time. Can you please help me see why the value is not updated? I am attaching my varSRF code (which is based on your mSRF code). I am also attaching an image of my SRFProperties file. Than you in advance. Best, Hiral Last edited by user_HH; January 19, 2021 at 21:27. |
|
January 20, 2021, 15:28 |
Update
|
#14 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
Alexey,
I tried overwriting the Su(), omega() and U() based on your approach as mentioned in the earlier replies on this post. However, when I print the value of omega_ through the "Info<<"Current RPM"<<omega_<<endl" in the Su() function in rpm.C (varrpm.C in my case), I still see that the value hasn't been updated. Any help to update the value of omega() and then to calculate updated Fcentrifugal(), Fcorioilis(), U(), Uabs(), velocity(), etc. in the SRF model will be highly appreciated. Thanks in advance. Best, Hiral |
|
January 21, 2021, 19:33 |
Update
|
#15 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
The code for variable rpm for SRF works. The issue was due to the my error with the virtual method. After correcting the error i see that the omega_ value is updated at every time step.
Thank you for the help. Best, Hiral |
|
April 21, 2021, 15:27 |
|
#16 |
New Member
Chan Siyu
Join Date: Jan 2021
Posts: 1
Rep Power: 0 |
Greating!
I followed your code and also meet your issue that the omega_ value doesn't change. You said that it is a error about the virtual method, but I am not good at C++ at all. I am learning about coding but I still have no idea about the issue. Could you please share more details with me? Thank you very much! Chan |
|
April 26, 2021, 09:31 |
|
#17 |
New Member
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7 |
@Chan Siyu,
In your mSRFModel.H file, when you declare the function "tmp<volVectorField::Internel> Su();", add the word virtual in the beginning. So the modified statement should be "virtual tmp<volVectorField::Internel> Su();" (everything should be without the double quotes). By making this change, the program can access the new Su() function defined in mrpm.C file. Thus, the value of omega, which is defined in Su()will be updated at every timestep. Hope this helps. Best, HH |
|
Tags |
omega, srf, table (time) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field | lakeat | OpenFOAM Community Contributions | 58 | December 23, 2021 03:36 |
Extrusion with OpenFoam problem No. Iterations 0 | Lord Kelvin | OpenFOAM Running, Solving & CFD | 8 | March 28, 2016 12:08 |
Sudden jump in Courant number | NJG | OpenFOAM Running, Solving & CFD | 7 | May 15, 2014 14:52 |
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 | bookie56 | OpenFOAM Installation | 8 | August 13, 2011 05:03 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |