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

rpm as function of time in SRF model ?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 9, 2015, 19:03
Default rpm as function of time in SRF model ?
  #1
New Member
 
Ron Bardell
Join Date: Aug 2012
Posts: 3
Rep Power: 6
rbardell is on a distinguished road
Sponsored Links
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
Sponsored Links

Old   March 10, 2015, 03:02
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,683
Rep Power: 27
alexeym will become famous soon enoughalexeym will become famous soon enough
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, 18:43
Default
  #3
New Member
 
Ron Bardell
Join Date: Aug 2012
Posts: 3
Rep Power: 6
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, 13 views)
File Type: h varyingRpm.H (2.7 KB, 8 views)
File Type: txt compileErr.txt (5.0 KB, 2 views)
rbardell is offline   Reply With Quote

Old   March 11, 2015, 09:28
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,683
Rep Power: 27
alexeym will become famous soon enoughalexeym will become famous soon enough
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, 03:40
Default
  #5
New Member
 
Ron Bardell
Join Date: Aug 2012
Posts: 3
Rep Power: 6
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, 3 views)
File Type: c SRFModel.C (5.9 KB, 6 views)
File Type: h varyingRpm.H (2.7 KB, 2 views)
File Type: c varyingRpm.C (2.6 KB, 6 views)
rbardell is offline   Reply With Quote

Old   March 14, 2015, 12:47
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,683
Rep Power: 27
alexeym will become famous soon enoughalexeym will become famous soon enough
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, 18 views)
File Type: gz rotor2D.tar.gz (6.1 KB, 6 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: 10
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.
otm is offline   Reply With Quote

Reply

Tags
omega, srf, table (time)

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM Running, Solving & CFD 8 March 28, 2016 11:08
Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Mesh Utilities 57 February 1, 2015 09:25
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 19:07

Sponsored Links


All times are GMT -4. The time now is 11:31.