CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] how can use Cp and Cv in Swak variables?

Register Blogs Community New Posts Updated Threads Search

Like Tree11Likes
  • 1 Post By gschaider
  • 1 Post By gschaider
  • 2 Post By wyldckat
  • 3 Post By wyldckat
  • 2 Post By gschaider
  • 2 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 10, 2013, 16:18
Default how can use Cp and Cv in Swak variables?
  #1
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
in below function if I want to use Cp/Cv instead of constant gamma that Cp and Cv can be calculated by the solver how I could do it?
Code:
totalPressure_left
       {
        type swakExpression;
        valueType patch;
        patchName left;
        accumulations (
            average
        );
        variables (
            "gamma=1.4;"
            "R=287.14;"
        );
        expression "sum(p*(pow(1+(gamma-1)/2*magSqr(U)/(gamma*R*T),(gamma/(gamma-1))))*rho*area())/sum(rho*area())";
        verbose true;
        outputControlMode outputTime;
        outputInterval 1;
       }
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 12, 2013, 12:12
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
in below function if I want to use Cp/Cv instead of constant gamma that Cp and Cv can be calculated by the solver how I could do it?
That depends on the OF-version and the solver you're using. Sometimes these fields are already found in memory and are found under different names: cv, Cv or thermo:cv (for the last one you'll need to use the alias-feature which is discussed elsewhere and documented - so don't ask)

Otherwise there are functions that get these fields in the swakThermophysicalFunctions-plugin
immortality likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 15, 2013, 19:10
Default
  #3
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
Hi Bernhard
thanks for guidance.
I managed to do that in Swak postProcessing functions with the help of dear Bruno through your advice.
now I want to use Cp and Cv in groovyBC variables but it dowsn't know Cp and Cv opposite to postProcessing functions.
this is the error I get:
Code:
[3] --> FOAM FATAL ERROR:
[3]
[1]
[1] --> FOAM FATAL ERROR:
[1]  Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor1/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[1]
From function ConcretePluginFunction<DriverType>::exists
Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor3/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[3]
[3]
[3]     From function parsingValue
[3]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160[1]
[1]     From function parsingValue
[1]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160..
[3]
FOAM parallel run exiting
[3]

[1]
FOAM parallel run exiting
[1]
[2]
[2] --> FOAM FATAL ERROR: --------------------------------------------------------------------------
MPI_ABORT was invoked on rank 3 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------

[2]  Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor2/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[2]
[2]
[2]     From function parsingValue
[2]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160.
[2]
FOAM parallel run exiting
[2]
in file lnInclude/ConcretePluginFunction.C at line 111
Constructor table of plugin functions for PatchValueExpressionDriver is not initialized
[0]
[0]
[0] --> FOAM FATAL ERROR:
[0]  Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor0/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[0]
[0]
[0]     From function parsingValue
[0]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160.
[0]
FOAM parallel run exiting
[0]
--------------------------------------------------------------------------
mpirun has exited due to process rank 2 with PID 26488 on
node Ehsan-com exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------
[Ehsan-com:26483] 3 more processes have sent help message help-mpi-api.txt / mpi-abort
[Ehsan-com:26483] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages

gnuplot> plot 
     
gnuplot> plot 
                       ^
 ^
                 line 0: line 0: function to plot expected

function to plot expected


gnuplot> set terminal png small color
                
gnuplot> set terminal png small color
                                ^
                    line 0:   invalid color spec, must be xRRGGBB 

  ^
         line 0: invalid color spec, must be xRRGGBB
gnuplot> plot 


        
gnuplot> plot 
            ^
                ^
  line 0:  function to plot expected 

      line 0: function to plot expected

Warning: empty x range [0.00101902:0.00101902], adjusting to [0.00100883:0.00102921]

gnuplot> plot "/tmp/tmp2m8WmU.gnuplot/fifo" title "rhoUy" with lines, "/tmp/tmpDE20xb.gnuplot/fifo" title "rhoUx" with lines, "/tmp/tmp4mA5Zt.gnuplot/fifo" title "rho" with lines
                                                                                                                                                                                  ^
         line 0: all points y value undefined!


gnuplot> set terminal png small color
                                ^
         line 0: invalid color spec, must be xRRGGBB

Killing PID 26479
 PyFoam WARNING on line 232 of file /usr/local/lib/python2.7/dist-packages/PyFoam/Execution/FoamThread.py : Process 26479 was already dead 
Warning: empty x range [0.00101902:0.00101902], adjusting to [0.00100883:0.00102921]

gnuplot> plot "/tmp/tmpkrENOz.gnuplot/fifo" title "rhoUy" with lines, "/tmp/tmpwHPZfe.gnuplot/fifo" title "rhoUx" with lines, "/tmp/tmpgEngiQ.gnuplot/fifo" title "rho" with lines
                                                                                                                                                                                  ^
         line 0: all points y value undefined!
I put these functions in controlDict and works well for outputs:
Code:
loadThermo {
        type loadPsiThermoModel;
        correctModel true;//I think that if "correctModel" is set to "true", it will call "thermo.correct()" at the beginning of each time iteration.
        //        correctModel true;
        allowReload false;//it's possibly for keeping track of the changes in "constant/thermo*"
        failIfModelTypeExists false;
        outputControlMode timeStep;
        outputInterval 1;
    }
     
    CvField {
        type expressionField;
        autowrite true;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cv()";
        fieldName Cv;
    }

    CpField {
        type expressionField;
        autowrite true;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cp()";
        fieldName Cp;
    }
but for groovyBC gives that error above.
in variables of groovyBC I wrote these terms in both patches for all variables(fields):
Code:
"gamma2=Cp/Cv;"
                  "gamma4=Cp/Cv;"
                  "R=Cp-Cv;"
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 16, 2013, 07:14
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
The problem is probably that the expressionField is created AFTER it is needed by groovyBC. This situation is ugly to work around.

Anyway. Before you proceed try removing Cp/Cv temporarily from the groovyBC/functions and use the listRegisteredObjects-functionObject to see if a fitting field is there. Maybe under a different name

Quote:
Originally Posted by immortality View Post
Hi Bernhard
thanks for guidance.
I managed to do that in Swak postProcessing functions with the help of dear Bruno through your advice.
now I want to use Cp and Cv in groovyBC variables but it dowsn't know Cp and Cv opposite to postProcessing functions.
this is the error I get:
Code:
[3] --> FOAM FATAL ERROR:
[3]
[1]
[1] --> FOAM FATAL ERROR:
[1]  Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor1/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[1]
From function ConcretePluginFunction<DriverType>::exists
Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor3/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[3]
[3]
[3]     From function parsingValue
[3]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160[1]
[1]     From function parsingValue
[1]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160..
[3]
FOAM parallel run exiting
[3]

[1]
FOAM parallel run exiting
[1]
[2]
[2] --> FOAM FATAL ERROR: --------------------------------------------------------------------------
MPI_ABORT was invoked on rank 3 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------

[2]  Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor2/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[2]
[2]
[2]     From function parsingValue
[2]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160.
[2]
FOAM parallel run exiting
[2]
in file lnInclude/ConcretePluginFunction.C at line 111
Constructor table of plugin functions for PatchValueExpressionDriver is not initialized
[0]
[0]
[0] --> FOAM FATAL ERROR:
[0]  Parser Error for driver PatchValueExpressionDriver at "1.1-2" :"field Cp not existing or of wrong type"
"Cp/Cv"
^^
--|

Context of the error:


- From dictionary: /home/ehsan/Desktop/WR_4/processor0/0.001019/U.boundaryField.right
Evaluating expression "Cp/Cv"
[0]
[0]
[0]     From function parsingValue
[0]     in file lnInclude/CommonValueExpressionDriverI.H at line 1160.
[0]
FOAM parallel run exiting
[0]
--------------------------------------------------------------------------
mpirun has exited due to process rank 2 with PID 26488 on
node Ehsan-com exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------
[Ehsan-com:26483] 3 more processes have sent help message help-mpi-api.txt / mpi-abort
[Ehsan-com:26483] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages

gnuplot> plot 
     
gnuplot> plot 
                       ^
 ^
                 line 0: line 0: function to plot expected

function to plot expected


gnuplot> set terminal png small color
                
gnuplot> set terminal png small color
                                ^
                    line 0:   invalid color spec, must be xRRGGBB 

  ^
         line 0: invalid color spec, must be xRRGGBB
gnuplot> plot 


        
gnuplot> plot 
            ^
                ^
  line 0:  function to plot expected 

      line 0: function to plot expected

Warning: empty x range [0.00101902:0.00101902], adjusting to [0.00100883:0.00102921]

gnuplot> plot "/tmp/tmp2m8WmU.gnuplot/fifo" title "rhoUy" with lines, "/tmp/tmpDE20xb.gnuplot/fifo" title "rhoUx" with lines, "/tmp/tmp4mA5Zt.gnuplot/fifo" title "rho" with lines
                                                                                                                                                                                  ^
         line 0: all points y value undefined!


gnuplot> set terminal png small color
                                ^
         line 0: invalid color spec, must be xRRGGBB

Killing PID 26479
 PyFoam WARNING on line 232 of file /usr/local/lib/python2.7/dist-packages/PyFoam/Execution/FoamThread.py : Process 26479 was already dead 
Warning: empty x range [0.00101902:0.00101902], adjusting to [0.00100883:0.00102921]

gnuplot> plot "/tmp/tmpkrENOz.gnuplot/fifo" title "rhoUy" with lines, "/tmp/tmpwHPZfe.gnuplot/fifo" title "rhoUx" with lines, "/tmp/tmpgEngiQ.gnuplot/fifo" title "rho" with lines
                                                                                                                                                                                  ^
         line 0: all points y value undefined!
I put these functions in controlDict and works well for outputs:
Code:
loadThermo {
        type loadPsiThermoModel;
        correctModel true;//I think that if "correctModel" is set to "true", it will call "thermo.correct()" at the beginning of each time iteration.
        //        correctModel true;
        allowReload false;//it's possibly for keeping track of the changes in "constant/thermo*"
        failIfModelTypeExists false;
        outputControlMode timeStep;
        outputInterval 1;
    }
     
    CvField {
        type expressionField;
        autowrite true;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cv()";
        fieldName Cv;
    }

    CpField {
        type expressionField;
        autowrite true;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cp()";
        fieldName Cp;
    }
but for groovyBC gives that error above.
in variables of groovyBC I wrote these terms in both patches for all variables(fields):
Code:
"gamma2=Cp/Cv;"
                  "gamma4=Cp/Cv;"
                  "R=Cp-Cv;"
immortality likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 16, 2013, 07:50
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@Bernhard: Ehsan forgot to update this thread. I had a look into this and answered him via email.
The problem about "Cv" and "Cp" is that these fields are apparently also managed by some other class and they were unregistered at the end/beginning of the following time iteration. By renaming the field names to "CRRv" and "CRRp" in the function objects, it seemed to work just fine.

I'll take the opportunity to consolidate the information I've been sending him over email. The following information was initially based on the example case "Examples/Lagrangian/hotStream" from swak4Foam:
  • The following function objects are the latest ones that seem to work as intended:
    Code:
    loadThermo {
        type loadPsiThermoModel;
        correctModel false;
        //        correctModel true;
        allowReload false;
        failIfModelTypeExists false;
        outputControl timeStep;
        outputInterval 1;
    }
    
    cvField {
        type expressionField;
        autowrite false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cv()";
        fieldName CRRv;
    }
    
    cpField {
        type expressionField;
        autowrite false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cp()";
        fieldName CRRp;
    }
  • Don't forget to add "libswakThermoTurbFunctionPlugin.so" to the "libs" list, e.g.:
    Code:
    libs (
       "libOpenFOAM.so"
       "libgroovyBC.so"
       "libsimpleSwakFunctionObjects.so"
       "libswakFunctionObjects.so"
       "libfieldFunctionObjects.so"
       "libswakThermoTurbFunctionPlugin.so"
    );
  • The "autowrite" option is whether the field should be saved at each time snapshot.
  • I think that if "correctModel" is set to "true", it will call "thermo.correct()" at the beginning of each time iteration. As for "allowReload", it's possibly for keeping track of the changes in "constant/thermo*".
Best regards,
Bruno
jherb and immortality like this.
__________________
wyldckat is offline   Reply With Quote

Old   August 16, 2013, 14:01
Default
  #6
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
Hi
whats the problem with reconstructPar about CRRv?
Code:
Create time



Reconstructing fields for mesh region0

Time = 0.002216

Reconstructing FV fields

    Reconstructing volScalarFields

        ddt0(rho,k)
        mut
        rho
        gas
        k
        gas_0
        alphat
        CRRv


--> FOAM FATAL IO ERROR: 
error in IOstream "/home/ehsan/Desktop/WR_4/processor2/0.002216/CRRv" for operation operator>>(Istream&, List<T>&) : reading entry

file: /home/ehsan/Desktop/WR_4/processor2/0.002216/CRRv at line 4647.

    From function IOstream::fatalCheck(const char*) const
    in file db/IOstreams/IOstreams/IOstream.C at line 114.

FOAM exiting
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 16, 2013, 14:14
Default
  #7
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
There are a few possibilities:
  • Insufficient disk space.
  • The file "CRRv" might be damaged for some reason.
  • You might have NaN values or similar inside the "CRRv" file.
The bullet-proof way to confirm what the problem is, is to visually inspect the file and line that the error message is telling you:
Quote:
Code:
file: /home/ehsan/Desktop/WR_4/processor2/0.002216/CRRv at line 4647.
Both gedit and kate allow you to jump directly to the line in question.
Or you can do it directly from the command line:
Code:
sed '4647!d' processor2/0.002216/CRRv
To see the lines before and after as well:
Code:
sed '4646,4648!d' processor2/0.002216/CRRv
__________________
wyldckat is offline   Reply With Quote

Old   August 16, 2013, 14:40
Default
  #8
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
Hi Bruno
but there is not CRRv,maybe its because of using ctrl+c.
ehsan@Ehsan-com:~/Desktop/WR_4$ sed '4647!d' processor2/0.002216/CRRv
sed: can't read processor2/0.002216/CRRv: No such file or directory
immortality is offline   Reply With Quote

Old   August 16, 2013, 14:58
Default
  #9
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by immortality View Post
but there is not CRRv,maybe its because of using ctrl+c.
ehsan@Ehsan-com:~/Desktop/WR_4$ sed '4647!d' processor2/0.002216/CRRv
sed: can't read processor2/0.002216/CRRv: No such file or directory
I'm honestly having a hard time to find words to answer to this...

Let me see if I understand this correctly: instead of checking if the file actually existed or not and what contents it had, as the error message clearly stated that something was wrong with this file, you instead went here to the forum to ask something that only you could see on your computer... which is somewhat common... for beginners!!!
You've been working with OpenFOAM for so long now, that these kinds of questions should no longer occur!


Either way, why on Earth are you still using Ctrl+C? I sent you the other day via email the function object that helps to stop the solver, by simply creating a file named "stop". I'll remind you how it works:
  1. Add the following code to "system/controlDict", inside the functions entry, add this code:
    Code:
    CtrlCReplacement
    {
      type abort;
      functionObjectLibs ( "libjobControl.so" );
      action noWriteNow; //nextWrite writeNow
      fileName "stop";
    }
    • For other readers, the "system/controlDict" would look something like this:
      Code:
      FoamFile
      {
          version 2.0;
          format ascii;
          class dictionary;
          location "system";
          object controlDict;
      }
      
      application icoFoam;
      
      startFrom startTime;
      
      startTime 0;
      
      stopAt endTime;
      
      endTime 0.5;
      
      deltaT 0.005;
      
      writeControl timeStep;
      
      writeInterval 20;
      
      purgeWrite 0;
      
      writeFormat ascii;
      
      writePrecision 6;
      
      writeCompression off;
      
      timeFormat general;
      
      timePrecision 6;
      
      runTimeModifiable true;
      
      functions
      {
        CtrlCReplacement
        {
          type abort;
          functionObjectLibs ( "libjobControl.so" );
          action noWriteNow; //nextWrite writeNow
          fileName "stop";
        }
      }
  2. Now, next time you want to use Ctrl+C, you should instead run the following command on another terminal tab/window, inside the same folder of the case you are running:
    Code:
    touch stop
    The function object "abort", as soon as it sees this new file "stop", will stop the solver at the end of the current time iteration.
    This way you will no longer have broken results. In addition, you can also change the action to one of the other two options.
arvindpj, immortality and Imran358 like this.
wyldckat is offline   Reply With Quote

Old   August 16, 2013, 16:46
Default
  #10
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
Hi Bruno
sorry,I had to leave and hadn't enough time to use touch stop and also was confused with various jobs should be done.CRRv file was there in fact,I saw that at the moment but was empty or incomplete because it couldn't be unzip and also CRRp didn't exist there.now I deleted four time folders and used previous time folder by reconstructPar -latestTime and worked fine.
I'm glad and it seems it made an opportunity for others to use the command you provided with my troubles and mentioned here.
thanks a lot.
immortality is offline   Reply With Quote

Old   August 18, 2013, 20:07
Default
  #11
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by wyldckat View Post
Greetings to all!

@Bernhard: Ehsan forgot to update this thread. I had a look into this and answered him via email.
The problem about "Cv" and "Cp" is that these fields are apparently also managed by some other class and they were unregistered at the end/beginning of the following time iteration. By renaming the field names to "CRRv" and "CRRp" in the function objects, it seemed to work just fine.
Thanks for the clarification
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 5, 2013, 08:26
Post heat transfer simulation at walls
  #12
New Member
 
Join Date: Dec 2013
Posts: 4
Rep Power: 12
Twig is on a distinguished road
Hello I don't want to steal this thread but I think my Problem is quite similar to the problem of immortality. I hope this is okay.

I want to simulate a reactor. The upper part is heated from the outside and in the lower part where the flame is burning there should be like it is normal the heat transfer to the outside. I use of swak4Foam groovyBC to implement this heat transfer. If I try to run the simulation my error looks like this.

Code:
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 2.2.2-9240f8b967db
Exec   : reactingFoam
Date   : Dec 05 2013
Time   : 12:19:52
Host   : "Martin"
PID    : 2416
Case   : /home/martin/OpenFOAM/martin-2.2.2/run/tutorials/combustion/reactingFoam/ras/Versuche_LVA/1_Versuch
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


Reading g
Creating reaction model

Selecting combustion model PaSR<psiChemistryCombustion>
Selecting chemistry type 
{
    chemistrySolver ode;
    chemistryThermo psi;
}

Selecting thermodynamics package 
{
    type            hePsiThermo;
    mixture         reactingMixture;
    transport       sutherland;
    thermo          janaf;
    energy          sensibleEnthalpy;
    equationOfState perfectGas;
    specie          specie;
}

Selecting chemistryReader foamChemistryReader
chemistryModel: Number of species = 5 and reactions = 1
Selecting ODE solver SIBS
Reading field U

Reading/calculating face flux field phi

Creating turbulence model.

Selecting turbulence model type RASModel
Selecting RAS turbulence model realizableKE
realizableKECoeffs
{
    Cmu             0.09;
    A0              4;
    C2              1.9;
    alphak          1;
    alphaEps        0.833333;
    alphah          1;
    sigmak          1;
    sigmaEps        1.2;
    Prt             1;
}

Creating field dpdt

Creating field kinetic energy K

No finite volume options present

Courant Number mean: 0.000425762 max: 2.81585

PIMPLE: Operating solver in PISO mode


Starting time loop

Courant Number mean: 3.02387e-05 max: 0.199989
deltaT = 7.10227e-05
Time = 7.10227e-05

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for O2, Initial residual = 1, Final residual = 6.25475e-07, No Iterations 20
DILUPBiCG:  Solving for H2O, Initial residual = 1, Final residual = 6.18374e-07, No Iterations 22
DILUPBiCG:  Solving for CH4, Initial residual = 1, Final residual = 6.24701e-07, No Iterations 23
DILUPBiCG:  Solving for CO2, Initial residual = 1, Final residual = 6.70893e-07, No Iterations 23
swak4Foam: Setting default mesh
swak4Foam: Allocating new repository for sampledGlobalVariables
--> FOAM Warning : 
    From function ConcretePluginFunction<DriverType>::exists
    in file lnInclude/ConcretePluginFunction.C at line 111
    Constructor table of plugin functions for PatchValueExpressionDriver is not initialized


--> FOAM FATAL ERROR: 
 Parser Error for driver PatchValueExpressionDriver at "1.9-10" :"field Cp not existing or of wrong type"
"average(Cp)"
          ^^
----------| 

Context of the error:


- Driver constructed from scratch
  Evaluating expression "average(Cp)"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1081.

FOAM exiting
So the problem is the definition of cp, but I thought as I implemented it in the T boundary condition with groovyBC that it is already defined?
I use OpenFoam 2.2.2 and the Version of swak4Foam which wyldcat posted (swak4Foam-master). I think this is the Version 0.2.4 but I am not sure.

Thanks a lot for your time and help.
Best regards Martin
Twig is offline   Reply With Quote

Old   December 5, 2013, 12:56
Default
  #13
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Twig View Post
Hello I don't want to steal this thread but I think my Problem is quite similar to the problem of immortality. I hope this is okay.

I want to simulate a reactor. The upper part is heated from the outside and in the lower part where the flame is burning there should be like it is normal the heat transfer to the outside. I use of swak4Foam groovyBC to implement this heat transfer. If I try to run the simulation my error looks like this.

Code:
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 2.2.2-9240f8b967db
Exec   : reactingFoam
Date   : Dec 05 2013
Time   : 12:19:52
Host   : "Martin"
PID    : 2416
Case   : /home/martin/OpenFOAM/martin-2.2.2/run/tutorials/combustion/reactingFoam/ras/Versuche_LVA/1_Versuch
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


Reading g
Creating reaction model

Selecting combustion model PaSR<psiChemistryCombustion>
Selecting chemistry type 
{
    chemistrySolver ode;
    chemistryThermo psi;
}

Selecting thermodynamics package 
{
    type            hePsiThermo;
    mixture         reactingMixture;
    transport       sutherland;
    thermo          janaf;
    energy          sensibleEnthalpy;
    equationOfState perfectGas;
    specie          specie;
}

Selecting chemistryReader foamChemistryReader
chemistryModel: Number of species = 5 and reactions = 1
Selecting ODE solver SIBS
Reading field U

Reading/calculating face flux field phi

Creating turbulence model.

Selecting turbulence model type RASModel
Selecting RAS turbulence model realizableKE
realizableKECoeffs
{
    Cmu             0.09;
    A0              4;
    C2              1.9;
    alphak          1;
    alphaEps        0.833333;
    alphah          1;
    sigmak          1;
    sigmaEps        1.2;
    Prt             1;
}

Creating field dpdt

Creating field kinetic energy K

No finite volume options present

Courant Number mean: 0.000425762 max: 2.81585

PIMPLE: Operating solver in PISO mode


Starting time loop

Courant Number mean: 3.02387e-05 max: 0.199989
deltaT = 7.10227e-05
Time = 7.10227e-05

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for O2, Initial residual = 1, Final residual = 6.25475e-07, No Iterations 20
DILUPBiCG:  Solving for H2O, Initial residual = 1, Final residual = 6.18374e-07, No Iterations 22
DILUPBiCG:  Solving for CH4, Initial residual = 1, Final residual = 6.24701e-07, No Iterations 23
DILUPBiCG:  Solving for CO2, Initial residual = 1, Final residual = 6.70893e-07, No Iterations 23
swak4Foam: Setting default mesh
swak4Foam: Allocating new repository for sampledGlobalVariables
--> FOAM Warning : 
    From function ConcretePluginFunction<DriverType>::exists
    in file lnInclude/ConcretePluginFunction.C at line 111
    Constructor table of plugin functions for PatchValueExpressionDriver is not initialized


--> FOAM FATAL ERROR: 
 Parser Error for driver PatchValueExpressionDriver at "1.9-10" :"field Cp not existing or of wrong type"
"average(Cp)"
          ^^
----------| 

Context of the error:


- Driver constructed from scratch
  Evaluating expression "average(Cp)"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1081.

FOAM exiting
So the problem is the definition of cp, but I thought as I implemented it in the T boundary condition with groovyBC that it is already defined?
I use OpenFoam 2.2.2 and the Version of swak4Foam which wyldcat posted (swak4Foam-master). I think this is the Version 0.2.4 but I am not sure.

Thanks a lot for your time and help.
Best regards Martin
I think the problem is that nowadays Cp is available as thermo:cp (or thermo:Cp or something else. But I'm pretty sure about the thermo: ). The problem with the : in the name is that it is already used by the parser. So you'll have to define an alias with it
Code:
aliases {
   //  thermo:cp myCp;
    myCp thermo:cp;
}
(I'm doing this from memory. Please check the docu). To get a list of the actually present fields you can use the listRegisteredObjects-functionObject
nimasam and immortality like this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

Last edited by gschaider; December 8, 2016 at 17:12. Reason: Used dictionary wrong
gschaider is offline   Reply With Quote

Old   December 6, 2013, 08:23
Default
  #14
New Member
 
Join Date: Dec 2013
Posts: 4
Rep Power: 12
Twig is on a distinguished road
Thanks a lot for your answer but now I have more questions.

How and where I can use the listRegisteredObjects-functionObject? I tried it in the terminal directly in the swak4Foam folder, but it want not work?

Where I have to implement the aliases into the controlDict?

Sorry for these question which maybe sounds to you trivial but I just started to use OpenFoam and therefore I am already not really familiar with some parts of it.

Again thanks a lot for your time and help.

Best regards Martin
Twig is offline   Reply With Quote

Old   December 6, 2013, 11:21
Default
  #15
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Twig View Post
Thanks a lot for your answer but now I have more questions.

How and where I can use the listRegisteredObjects-functionObject? I tried it in the terminal directly in the swak4Foam folder, but it want not work?
Usually
Code:
grep -r listRegist Examples/*
is your friend: it will find you some usage-examples

Quote:
Originally Posted by Twig View Post
Where I have to implement the aliases into the controlDict?
Either look it up in the reference guide or use the grep-trick again. Or have a look at the README (where it is described like every other new feature)

Quote:
Originally Posted by Twig View Post
Sorry for these question which maybe sounds to you trivial but I just started to use OpenFoam and therefore I am already not really familiar with some parts of it.
You've got to understand my problem: I give you the name of the thing that helps you (listRegisteredObjects) and then expect you to do a minimum of research yourself. The reason is that every time I describe something in detail (especially if I described it several times before on the MessageBoard - You are aware that it has a search function) another paragraph of the documentation does NOT get written (I only have limited time for non-customer-support). The alternative would be that I stop answering redundant questions altogether and with the time saved in half a year there would be a complete reference guide for swak. That half year would be hard for some.
immortality and mnikku like this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 9, 2013, 05:17
Default
  #16
New Member
 
Join Date: Dec 2013
Posts: 4
Rep Power: 12
Twig is on a distinguished road
Thanks a lot for your help. You're right I am sorry for my questions in the future I will do more research before I ask something.

Thank you very much!

Best regards Martin
Twig is offline   Reply With Quote

Old   December 8, 2016, 10:48
Default
  #17
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Dear Bernhard,

I have similar issue with the variable defined in meltingandsolidification source in OF 3.0 and ahead.

details are given in post #1

Quote:
GFlAvg
{
aliases {
sMS1:alpha1 myfl;
// thermo:cp myCp;
}
type swakExpression;
valueType cellZone;
zoneName solid; // or whatever is your zoneName
accumulations (
average
);

expression "myfl";
verbose true;
// outputControlMode timeStep;
// outputInterval 1;
}
but " aliases { sMS1:alpha1 myfl; }" is not recognised with OF3.X and the corresponding version of Swak4Foam

Also I have tried to list the variables using following commands

Quote:
name4me
{
type writeRegisteredObject;
functionObjectLibs ( "libIOFunctionObjects.so" );
objectNames ();
outputControl outputTime;
outputInterval 1;
}
testing
{
type writeRegisteredObject;
functionObjectLibs ( "libIOFunctionObjects.so" );
objectNames ("bananas");
outputControl outputTime;
}
----but no success

But I am pretty sure about the name of the variable as I can operate with the variable in coded functions (banana trick works in coded functions but not with type writeRegisteredObject; )

please help, some how the variable "sMS1:alpha1" access with swakExpressions seem very necessary to me.

Thanks and regards.

Last edited by cfd@kgp; December 8, 2016 at 10:53. Reason: few more additions for clarity
cfd@kgp is offline   Reply With Quote

Old   December 8, 2016, 17:11
Default
  #18
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by cfd@kgp View Post
Dear Bernhard,

I have similar issue with the variable defined in meltingandsolidification source in OF 3.0 and ahead.

details are given in post #1

but " aliases { sMS1:alpha1 myfl; }" is not recognised with OF3.X and the corresponding version of Swak4Foam

Also I have tried to list the variables using following commands


----but no success

But I am pretty sure about the name of the variable as I can operate with the variable in coded functions (banana trick works in coded functions but not with type writeRegisteredObject; )

please help, some how the variable "sMS1:alpha1" access with swakExpressions seem very necessary to me.

Thanks and regards.
You've used the aliases dictionary wrong: your name is on the left. The Field you want to access on the right. That's the way dictionaries usually work

(looking down I saw that the confusion comes from one of my answers. But I put the disclaimer below the answer for a reason. I'll edit the answer)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 9, 2016, 02:04
Default
  #19
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 12
cfd@kgp is on a distinguished road
Quote:
Originally Posted by gschaider View Post
You've used the aliases dictionary wrong: your name is on the left. The Field you want to access on the right. That's the way dictionaries usually work

(looking down I saw that the confusion comes from one of my answers. But I put the disclaimer below the answer for a reason. I'll edit the answer)
Thanks a lot for Bernhard! your quick and precise reply was very helpful, it means a lot to me...
cfd@kgp is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 19:29.