|
[Sponsors] |
3D equation, loading values for variable Cp from txt file with time-value columns |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 29, 2015, 07:42 |
3D equation, loading values for variable Cp from txt file with time-value columns
|
#1 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi all,
I think my problem is similar as described above. I have to input a time varying variable Cp whose value is changing with time not space. I have 32 time points and 32 values of Cp. these values are listed in a text file and i have to read it from there.. Basically i am simulating a convection diffusion equation . I am pasting the code for better understanding... solve ( fvm::ddt(C) + (1/por)*fvm::div(phi, C) - fvm::laplacian(D, C) + fvm::Sp((ktrans/por), C) + fvm::Sp((lfc/por)*(p-lp), C) == (ktrans*Cp) ); In here Cp term (basically its concentration in moles) on RHS is time varying and changing for 32 time points. My problem is how i enter the time varying values of Cp as i am simulating this eqn for 32 time points to get C at each time point (total time 128 seconds with time difference of 4 sec so total 32 time points). I have list of 32 values of Cp for 32 time points... How I enter them for each time point?? or how i read my text file. I am pasting my text file also for better understanding.. time(sec) concentration(moles) 4 0.0 8 0.0 12 0.0 16 0.0 20 0.0 24 0.10108117 28 1.0127527 32 2.0 36 1.557599 40 1.131114 44 1.1927048 48 1.289628 52 1.295573 56 1.140025 60 1.038649 64 1.0607834 68 1.1071031 72 1.0575966 76 1.0918694 80 1.0274673 84 1.005336 88 0.9897777 92 0.93968034 96 0.932393 100 0.8909937 104 0.93785316 108 0.8845323 112 0.91211754 116 1.0066646 120 0.92081094 Any help will be appreciated... Regards Ajay |
|
December 29, 2015, 08:01 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Greetings Ajay,
I've moved your post from the other thread: http://www.cfd-online.com/Forums/ope...ampledict.html - to this new one, since the problems are somewhat different. The first problem is determining if you are solving a 0D or a 1D equation. I ask this because this affects how the "Cp" field is provided, as well as the other fields, such as C and D. Therefore, please provide more details about the case set-up you have. I ask this because the "Cp" field should either be:
Bruno
__________________
|
|
December 29, 2015, 11:49 |
|
#3 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi,
Thanks bruno for your quick reply.. Regarding your questions.. I am simulating a body tissue which is basically porous media. The above equation is basically a 3D equation means i am simulating C (concentration in tissue) in 3D. It is a volScalarField. D is diffusion constant and its value is 1e-09 and is uniform all over the mesh. ktrans and por are permeability coefficient and porosity which is non uniform and has been input on each cell in mesh. Mesh is rectangular with 45,30,10 cells in x,y,z directions respectively. pressure and velocity have been solved earlier by continuity and momentum equations. Now problem is that i am simulating the above equation for 30 time steps starting from 0 to 120 sec at interval of 4 sec. And at each time step Cp(concentration in capillaries) term is changing and i have a list of values which i have already mentioned above. I just want to read this text file and update Cp term at each time step to calculate C at each time step. Hope you understand Regards Ajay |
|
December 29, 2015, 12:27 |
|
#4 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Hi Ajay,
Without a working code to work on, I'll have to rely on a few quick notes:
Best regards, Bruno
__________________
|
|
December 30, 2015, 01:38 |
|
#5 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi bruno,
Thanks for your help. I did exactly as you have mentioned. I built the solver again. Solver was compiled succesfully. But when i am running the case Its giving following error.. Code:
--> FOAM FATAL ERROR: Different dimensions for = dimensions : [0 0 0 0 1 0 0] = [0 0 0 0 0 0 0] From function dimensionSet::operator=(const dimensionSet&) const in file dimensionSet/dimensionSet.C at line 171. FOAM aborting #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::error::abort() at ??:? #2 Foam::dimensionSet::operator=(Foam::dimensionSet const&) const at ??:? #3 ? at ??:? #4 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #5 ? at ??:? Aborted (core dumped) I have checked all the dimensions twice.. I don't know where is the error now. But i think error is in this line Code:
Cp = cpValue->value(mesh.time().timeOutputValue())); Regards Ajay |
|
December 30, 2015, 07:43 |
|
#6 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Hi Ajay,
Quote:
Knowing how you defined the Cp variable would make it easier to give a proper solution. Either way, the problem is that it cannot be a "scalar", it has to be "dimensionedScalar"... let me see if I can find an example in OpenFOAM's code... here's a command that helps find several examples: Code:
find $FOAM_UTILITIES $FOAM_SOLVERS -name "*.[CH]" -type f | xargs grep dimensionedScalar Code:
dimensionedScalar Cp("Cp", dimEnergy/dimTemperature, 0.0); dimensionedScalar Cp("Cp", dimensionSet(0, 2, -1 , 0, 0), 0.0); Best regards, Bruno
__________________
|
||
December 30, 2015, 11:53 |
|
#7 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi bruno,
I didn't get it means you are saying that in createfields.h file i replace this Code:
Info<< "Reading field Cp\n" << endl; volScalarField Cp ( IOobject ( "Cp", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Code:
dimensionedScalar Cp("Cp", dimensionSet(0 0 0 0 1 0 0), 0.0); |
|
December 30, 2015, 12:40 |
|
#8 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi bruno,
I have done the following changes in createFields,h Code:
IOdictionary cpDict ( IOobject ( "cpDict", mesh.time().constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); autoPtr<DataEntry<scalar> > cpValue(DataEntry<scalar>::New("cpValue", cpDict)); dimensionedScalar Cp ( cpDict.lookup("Cp") ); Code:
Cp Cp [0 0 0 0 1 0 0] 0; cpValue tableFile; cpValueCoeffs { fileName "$FOAM_CASE/myDataFile" outOfBounds clamp; } Solver is compiling but again case is not running and now error is Code:
--> FOAM FATAL IO ERROR: error in IOstream "/home/ajay/OpenFOAM/ajay-2.4.0/run/tutorials/incompressible/porousSimpleFoam/cncrnozeroporositytime/myDataFile" for operation operator>>(Istream&, List<T>&) : reading first token file: /home/ajay/OpenFOAM/ajay-2.4.0/run/tutorials/incompressible/porousSimpleFoam/cncrnozeroporositytime/myDataFile at line 1. From function IOstream::fatalCheck(const char*) const in file db/IOstreams/IOstreams/IOstream.C at line 114. FOAM exiting Regards Ajay Last edited by wyldckat; December 31, 2015 at 07:34. Reason: fixed broken end code marker |
|
December 31, 2015, 08:03 |
|
#9 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Hi Ajay,
That is very strange.... why did you try those lines of code that are not exactly as the examples I had given? The following should work: Code:
IOdictionary cpDict ( IOobject ( "cpDict", mesh.time().constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); autoPtr<DataEntry<scalar> > cpValue(DataEntry<scalar>::New("cpValue", cpDict)); dimensionedScalar Cp("Cp", dimensionSet(0, 0, 0, 0, 1, 0, 0), 0.0); Code:
Cp = cpValue->value(mesh.time().timeOutputValue()); Bruno
__________________
|
|
January 1, 2016, 02:13 |
|
#10 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi bruno,
FIrst a very happy new year to you.. I have done the same thing many times. i Have used the same code as you described above and compiled but again the error is same Code:
Different dimensions for = dimensions : [0 0 0 0 1 0 0] = [0 0 0 0 0 0 0] From function dimensionSet::operator=(const dimensionSet&) const in file dimensionSet/dimensionSet.C at line 171. FOAM aborting #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::error::abort() at ??:? #2 Foam::dimensionSet::operator=(Foam::dimensionSet const&) const at ??:? #3 ? at ??:? #4 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #5 ? at ??:? Aborted (core dumped) Code:
Cp = cpValue->value(mesh.time().timeOutputValue()); solve ( fvm::ddt(C) + (1/por)*fvm::div(phi, C) - fvm::laplacian(D, C) + fvm::Sp((ktrans/por), C) + fvm::Sp((lfc/por)*(p-lp), C) == (ktrans*Cp) ); Regards Ajay |
|
January 1, 2016, 04:20 |
|
#11 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi bruno,
Mission accomplished. There was minor error . Instead of this Code:
Cp = cpValue->value(mesh.time().timeOutputValue()); Code:
Cp.value() = cpValue->value(mesh.time().timeOutputValue()); |
|
January 1, 2016, 06:16 |
|
#12 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
Hi Ajay,
I'm glad you managed to figure it out! I only did a quick test yesterday and it seemed to have worked for me, but I didn't do much more testing with it. And a Happy New Year! Best regards, Bruno |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to calculate mass flow rate on patches and summation of that during the run? | immortality | OpenFOAM Post-Processing | 104 | February 16, 2021 09:46 |
SparceImage v1.7.x Issue on MAC OS X | rcarmi | OpenFOAM Installation | 4 | August 14, 2014 07:42 |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 06:18 |
plot over time | fferroni | OpenFOAM Post-Processing | 7 | June 8, 2012 08:56 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |