CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

rpm as function of time in SRF model ?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By otm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 9, 2015, 18:03
Default rpm as function of time in SRF model ?
  #1
New Member
 
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 13
rbardell is on a distinguished road
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.
rbardell is offline   Reply With Quote

Old   March 10, 2015, 02:02
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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_;
        ...
}
into this

Code:
class varyingRpm
:
    public SRFModel
{

        //- Revolutions per minute
        autoPtr<DataEntry<scalar> > rpm_;
        ...
}
Then you override SRFModel's omega, Fcoriolis, Fcentrifugal, velocity, U methods where you extract current value of rpm_ (first getting current time from mesh_), update omega_.value() and then call parent class methods.

You can find examples of DataEntry constructor and data interpolation in swirlFlowRateInletVelocityFvPatchVectorField.C.
alexeym is offline   Reply With Quote

Old   March 10, 2015, 17:43
Default
  #3
New Member
 
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 13
rbardell is on a distinguished road
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:
Originally Posted by alexeym View Post
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_;
        ...
}
into this

Code:
class varyingRpm
:
    public SRFModel
{

        //- Revolutions per minute
        autoPtr<DataEntry<scalar> > rpm_;
        ...
}
Then you override SRFModel's omega, Fcoriolis, Fcentrifugal, velocity, U methods where you extract current value of rpm_ (first getting current time from mesh_), update omega_.value() and then call parent class methods.

You can find examples of DataEntry constructor and data interpolation in swirlFlowRateInletVelocityFvPatchVectorField.C.
Attached Files
File Type: c varyingRpm.C (2.6 KB, 29 views)
File Type: h varyingRpm.H (2.7 KB, 16 views)
File Type: txt compileErr.txt (5.0 KB, 6 views)
rbardell is offline   Reply With Quote

Old   March 11, 2015, 08:28
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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);
You don't need this additional dictionary argument as SRFProperties dictionary is *this, and dictionary SRFModelCoeffs_ which is a member of SRFModel is varyingRpmCoeffs dictionary. So implementation of constructor could be like this:

Code:
Foam::SRF::varyingRpm::varyingRpm
(
    const volVectorField& U
)
:
    SRFModel(typeName, U),
    rpm_(DataEntry<scalar>::New("varyingRpm", SRFModelCoeffs_))
{
...
}
2. At this point the problem appears. SRFModel class does not allow to override omega, Fcoriolis, Fcentrifugal, etc methods. For some reason they are non-virtual. I don't see the solution except to reimplement SRFModel with virtual methods and then reimplement solver you are using to use new SRF framework. Maybe somebody else can suggest something simpler.
alexeym is offline   Reply With Quote

Old   March 12, 2015, 02:40
Default
  #5
New Member
 
Ron Bardell
Join Date: Aug 2012
Posts: 5
Rep Power: 13
rbardell is on a distinguished road
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:
Originally Posted by alexeym View Post
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);
You don't need this additional dictionary argument as SRFProperties dictionary is *this, and dictionary SRFModelCoeffs_ which is a member of SRFModel is varyingRpmCoeffs dictionary. So implementation of constructor could be like this:

Code:
Foam::SRF::varyingRpm::varyingRpm
(
    const volVectorField& U
)
:
    SRFModel(typeName, U),
    rpm_(DataEntry<scalar>::New("varyingRpm", SRFModelCoeffs_))
{
...
}
2. At this point the problem appears. SRFModel class does not allow to override omega, Fcoriolis, Fcentrifugal, etc methods. For some reason they are non-virtual. I don't see the solution except to reimplement SRFModel with virtual methods and then reimplement solver you are using to use new SRF framework. Maybe somebody else can suggest something simpler.
Attached Files
File Type: h SRFModel.H (4.6 KB, 27 views)
File Type: c SRFModel.C (5.9 KB, 17 views)
File Type: h varyingRpm.H (2.7 KB, 12 views)
File Type: c varyingRpm.C (2.6 KB, 16 views)
rbardell is offline   Reply With Quote

Old   March 14, 2015, 11:47
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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.
Attached Files
File Type: gz mSRF.tar.gz (9.3 KB, 45 views)
File Type: gz rotor2D.tar.gz (6.1 KB, 22 views)
alexeym is offline   Reply With Quote

Old   May 6, 2017, 15:59
Default Euler force
  #7
otm
New Member
 
Join Date: Jun 2009
Posts: 22
Rep Power: 17
otm is on a distinguished road
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,
F_{Euler}=-m\frac{d\overline{\omega}}{dt}\times \overline{r}

Another comment is that it doesn't make sense to me to have a non transient Simple solver with time varying rotation rate.
warnerchang likes this.
otm is offline   Reply With Quote

Old   January 7, 2021, 16:50
Default Error while compiling solver
  #8
New Member
 
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7
user_HH is on a distinguished road
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)

user_HH is offline   Reply With Quote

Old   January 12, 2021, 09:43
Default
  #9
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
@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
method, obvious question is: did you linked implementation of this method (mSRFModelNew.C file in mSRF archive)?

Next question is: how do you instantiate you SRF model?
alexeym is offline   Reply With Quote

Old   January 12, 2021, 10:16
Default
  #10
New Member
 
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7
user_HH is on a distinguished road
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
user_HH is offline   Reply With Quote

Old   January 13, 2021, 03:53
Default
  #11
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
@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.
alexeym is offline   Reply With Quote

Old   January 13, 2021, 09:26
Default
  #12
New Member
 
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7
user_HH is on a distinguished road
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
user_HH is offline   Reply With Quote

Old   January 18, 2021, 11:38
Default 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
user_HH is on a distinguished road
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
Attached Images
File Type: png SRFProperties_image.PNG (29.1 KB, 19 views)
Attached Files
File Type: gz varSRF.tar.gz (7.4 KB, 12 views)

Last edited by user_HH; January 19, 2021 at 20:27.
user_HH is offline   Reply With Quote

Old   January 20, 2021, 14:28
Default Update
  #14
New Member
 
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7
user_HH is on a distinguished road
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
user_HH is offline   Reply With Quote

Old   January 21, 2021, 18:33
Default Update
  #15
New Member
 
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7
user_HH is on a distinguished road
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
user_HH is offline   Reply With Quote

Old   April 21, 2021, 14:27
Default
  #16
New Member
 
Chan Siyu
Join Date: Jan 2021
Posts: 1
Rep Power: 0
Chan Siyu is on a distinguished road
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
Chan Siyu is offline   Reply With Quote

Old   April 26, 2021, 08:31
Default
  #17
New Member
 
HH
Join Date: Apr 2019
Posts: 17
Rep Power: 7
user_HH is on a distinguished road
@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
user_HH is offline   Reply With Quote

Reply

Tags
omega, srf, table (time)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM Running, Solving & CFD 8 March 28, 2016 11:08
Sudden jump in Courant number NJG OpenFOAM Running, Solving & CFD 7 May 15, 2014 13:52
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07


All times are GMT -4. The time now is 16:38.