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

Adapt InjectionModel

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

Like Tree1Likes
  • 1 Post By Scram_1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 23, 2016, 09:57
Default Adapt InjectionModel
  #1
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 150
Rep Power: 16
Chrisi1984 is on a distinguished road
Hello all,

I want to do a steady spray simulation (simpleReactingParcelFoam) in OpenFOAM 3.0.1. I have a list of injection sources, which includes injection position, injection velocity vector, density, diameter and mass.

I found the KinematicLookupTableInjection model, which looks perfect for this job. You can specify an input file with a list of x, y, z, u, v, w, d, rho and mDot entries, and with the correct settings each injector injects one parcel at the given position with the given velocity, density and diameter.
The only difficulty seem to be the mass flow rate, mDot. Each injected parcel has the same mass, independent on the mDot value given in the lookup table.

I then looked at the KinematicLookupTableInjection source, and sure enough, mDot is only used to calculate the total injected volume, and is not exposed to other parts of OpenFOAM:
Quote:
// KinematicLookupTableInjection.C, line 71 - 77
this->volumeTotal_ = 0.0;
forAll(injectors_, i)
{
this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
}
this->volumeTotal_ *= duration_;[/code]

[code]// KinematicLookupTableInjection.C, line 157 - 164
scalar volume = 0.0;
if ((time0 >= 0.0) && (time0 < duration_))
{
forAll(injectors_, i)
{
volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
}
}

I know that OpenFOAM usually injects every parcel with the same mass, and as I found out this is also the case for KinematicLookupTableInjection.

I also found a possible way to change this behavior, by modifying the InjectionModel class, more specifically the InjectionModel::injectSteadyState function. newVolumeFraction might be set dynamically by calling a (new) function in KinematicLookupTableInjection that returns a volumeFraction based on mDot of the current parceI.
However, it looks like I would need to recompile the complete OpenFOAM spray library when I change InjectionModel.C, as the file is included nearly everywhere. Is there an easy way to have a custom InjectionModel.C only for the modified version of KinematicLookupTableInjection, while leaving other injection models unchanged?

Any other way to specify a custom mass per parcel is also appreciated! Note that I would like to inject ~180,000 parcels, so I guess using 180,000 separate injection models with ManualInjection and a customly calculated mass is not a good way.


Kind regards and thanks for any help in advance!
Chrisi
Chrisi1984 is offline   Reply With Quote

Old   May 24, 2017, 09:54
Default
  #2
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Hi Chrisi

I have found the same problem as you, and think it's a bit of a flaw!

Did you get any further with your problem? I've added another column in the lookupTable called 'numParticles' which is supposed to give the number of parcels to inject. Although this works to give the total number of parcels each timestep, it doesn't give the correct number of parcels to inject on each injector which is what you mentioned too.

I'd be interested to hear what you've done.

Here is a link to a tutorial I made which shows the first steps of what I have done: http://www.tfd.chalmers.se/~hani/kur.../tutorial1.pdf

The application is slightly different, but you can get the gist.

Alasdair
ali.m.1 is offline   Reply With Quote

Old   May 24, 2017, 14:38
Default
  #3
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 150
Rep Power: 16
Chrisi1984 is on a distinguished road
Hello Alasdair,

what I did is to copy the existing KinematicLookupTableInjection model. Rename it to e.g. MyKinematicLookupTableInjection and copy the function "setNumberOfParticles" from the upper class InjectionModel to the end into your new class "MyKinematicLookupTableInjection". This is overwritting the function "setNumberOfParticles" which is included in the InjectionModel class.
Within MyKinematicLookupTableInjection class you can redefine this function "setNumberOfParticles" with your intended calculation based on massFlowRate so that not every parcel has the same mass.

Kind regards
Chrisi
Chrisi1984 is offline   Reply With Quote

Old   May 25, 2017, 11:24
Default
  #4
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Hi Chrisi

Thanks a lot for your idea. I'll give that a go. I think it's what I need. Good idea!

regards

Alasdair
ali.m.1 is offline   Reply With Quote

Old   June 23, 2017, 11:53
Default
  #5
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Hi Chrisi

I tried your idea but I couldn't get it to work.

Would you mind sharing your file for me to have a look at? This would be a great help to me!

kind regards

Alasdair
ali.m.1 is offline   Reply With Quote

Old   August 18, 2017, 11:25
Default
  #6
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Hello folks

I have managed to adapt the injection model as suggested, however there is still one issue.

In my injection model, I have the variable 'setNumberOfParticles', and this is currently a scalar. In the original injection model, you would set this to =2 (for example), and then each injection site would have 2 particles injected.

However, in my case I have a scalarList, in the form of the kinematicLookupTable. This has a number corresponding to each cell, of how many particles to inject.

So my question is, how can I turn nP into a scalarList, when it is currently a scalar?

It shouldn't be too difficult, but I can't figure it out...

setNumberOfParticles can be viewed in InjectionModel.C if you want to have a look at how it is defined.

Alasdair
ali.m.1 is offline   Reply With Quote

Old   September 1, 2017, 03:23
Default code
  #7
Senior Member
 
Join Date: Jan 2010
Location: Stuttgart
Posts: 150
Rep Power: 16
Chrisi1984 is on a distinguished road
Hello,

please find my example attached.

Kind regards
Chrisi
Attached Files
File Type: zip LookupTableInjection.zip (69.5 KB, 62 views)
Chrisi1984 is offline   Reply With Quote

Old   September 5, 2017, 07:20
Default
  #8
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Hi Chrisi

Thanks a lot for your message and code. The key thing I was missing was the 'currentInjector_', as I could not select each injector separately without this.

So thanks again! If anyone is interested I can post my working file up here.

Alasdair
ali.m.1 is offline   Reply With Quote

Old   March 4, 2018, 19:25
Default
  #9
Member
 
Join Date: Oct 2015
Posts: 63
Rep Power: 10
Scram_1 is on a distinguished road
Hi Alasdair,
Can you post your working file?
Also, I want to inject particles at different instants of time. Normally what we do is specify the SOI and then the desired particles are injected every time step. What I want to do is specify the time steps when particles must be injected. For instance, say 2 particles are injected in the first time step, 0 particles injected in the second, 5 particles in the third and so on. I can create a file which has the time steps and the particles injected in that time step. But how do I make the injection model read this?
Any help is greatly appreciated!!

Thanks!
Scram_1
sourav90 likes this.
Scram_1 is offline   Reply With Quote

Old   December 26, 2022, 15:44
Default
  #10
Member
 
Huan Zhang
Join Date: Nov 2020
Posts: 55
Rep Power: 5
Jasper Z is on a distinguished road
Quote:
Originally Posted by Scram_1 View Post
Hi Alasdair,
Can you post your working file?
Also, I want to inject particles at different instants of time. Normally what we do is specify the SOI and then the desired particles are injected every time step. What I want to do is specify the time steps when particles must be injected. For instance, say 2 particles are injected in the first time step, 0 particles injected in the second, 5 particles in the third and so on. I can create a file which has the time steps and the particles injected in that time step. But how do I make the injection model read this?
Any help is greatly appreciated!!

Thanks!
Scram_1
Dear Scram_1,

Have you figured out how to read the lookup table at each timestep? I am facing the same problem as yours. Please give me a hint, very appreciate!

Sincerely,
Jasper
Jasper Z is offline   Reply With Quote

Old   December 26, 2022, 17:25
Default
  #11
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
Please search around for my PhD Thesis, more info in that. Thanks
ali.m.1 is offline   Reply With Quote

Old   December 26, 2022, 17:26
Default
  #12
Member
 
Huan Zhang
Join Date: Nov 2020
Posts: 55
Rep Power: 5
Jasper Z is on a distinguished road
Quote:
Originally Posted by ali.m.1 View Post
Please search around for my PhD Thesis, more info in that. Thanks
Thank you so much for your quick reply!

Jasper
Jasper Z is offline   Reply With Quote

Old   December 26, 2022, 17:31
Default
  #13
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 66
Rep Power: 12
ali.m.1 is on a distinguished road
No probs, I remember how hard life is when scrolling through openfoam and on these forums.
ali.m.1 is offline   Reply With Quote

Old   December 26, 2022, 17:33
Default
  #14
Member
 
Huan Zhang
Join Date: Nov 2020
Posts: 55
Rep Power: 5
Jasper Z is on a distinguished road
Quote:
Originally Posted by ali.m.1 View Post
No probs, I remember how hard life is when scrolling through openfoam and on these forums.
You are so great and helped me a lot! Much appreciated!

Jasper
Jasper Z is offline   Reply With Quote

Reply

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
Yplus adapt rafash2 FLUENT 0 June 12, 2016 07:25
Implementing a new InjectionModel / RunTimeSelection Problems spv24 OpenFOAM Programming & Development 1 October 8, 2011 11:47
Creating Own InjectionModel spv24 Main CFD Forum 1 October 8, 2011 11:46
How to adapt region? gholamghar FLUENT 3 April 5, 2009 22:57
How to adapt lower phase in 3 D pipe flow K.Baker FLUENT 2 July 21, 2007 15:19


All times are GMT -4. The time now is 23:42.