Skip to content

Commit

Permalink
Add option of using linear interpolation
Browse files Browse the repository at this point in the history
Use linear interpolation to calcuate total cross section
when calculating the row index.

The option is provided in constant/dsmcProperties like

    He-He
    {
        deflectionAngleCosinTableFileName    "xiHe4Cl.csv";
        numRows                         900;
        numColumns                      500;
        G                               400.0;
        useInterpolatedSigmaT           yes;
    }
  • Loading branch information
zhulianhua committed Apr 1, 2019
1 parent 711a0ad commit 705c2fb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
36 changes: 33 additions & 3 deletions AbInitio.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ License
#include "constants.H"
#include "addToRunTimeSelectionTable.H"
#include "IFstream.H"
#include "Switch.H"

using namespace Foam::constant::mathematical;

Expand All @@ -51,7 +52,8 @@ Foam::AbInitio::AbInitioMatrix::AbInitioMatrix
numRows_(readLabel(dict.lookup("numRows"))),
numColumns_(readLabel(dict.lookup("numColumns"))),
G_(readScalar(dict.lookup("G"))),
separator_(dict.lookupOrDefault<string>("separator",string(","))[0])
separator_(dict.lookupOrDefault<string>("separator",string(","))[0]),
useInterpolatedSigmaT_(dict.lookupOrDefault<Switch>("useInterpolatedSigmaT", false))
{
// allocate the memory
deflectionAngleCosinTable_.setSize(numRows_*numColumns_);
Expand Down Expand Up @@ -117,8 +119,20 @@ inline Foam::scalar Foam::AbInitio::AbInitioMatrix::deflectionAngleCosin ( Foam:

inline Foam::scalar Foam::AbInitio::AbInitioMatrix::sigmaT ( Foam::scalar cR) const
{
label row = deflectionAngleRow(cR);
return sigmaTtable_[row];
if(useInterpolatedSigmaT_) {
label rowA, rowB;
deflectionAngleRowBetween(cR, rowA, rowB);
// recover the original cRA and cRB
// NOTE: can be pre-stored also in that matrix
scalar cRA = G_*(pow(1.005, rowA+1)-1.0);
scalar cRB = G_*(pow(1.005, rowB+1)-1.0);
return (cR - cRB)*(sigmaTtable_[rowA] - sigmaTtable_[rowB])/(cRA - cRB)
+ sigmaTtable_[rowB];
}
else{
label row = deflectionAngleRow(cR);
return sigmaTtable_[row];
}
}

inline Foam::label Foam::AbInitio::AbInitioMatrix::deflectionAngleRow(Foam::scalar cR) const
Expand All @@ -128,6 +142,21 @@ inline Foam::label Foam::AbInitio::AbInitioMatrix::deflectionAngleRow(Foam::scal
return j - 1;
}

void Foam::AbInitio::AbInitioMatrix::deflectionAngleRowBetween(Foam::scalar cR, Foam::label& rowA, Foam::label& rowB) const
{
Foam::label jb = floor(log(1+cR/G_)/log(1.005) + 0.5);
Foam::label ja = jb+1;

if (jb>numRows_)
{
ja = numRows_;
jb = numRows_;
}

rowA = ja-1;
rowB = jb-1;
}

Foam::AbInitio::AbInitio
(
const dictionary& dict,
Expand Down Expand Up @@ -164,6 +193,7 @@ Foam::AbInitio::AbInitio
if (i > j) AImatrixs_[i].set(j, new AbInitioMatrix(cloud, coeffDict_.subDict(componentP+'-'+componentQ)));
}
}

}

// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Expand Down
6 changes: 6 additions & 0 deletions AbInitio.H
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ public:
// store the sigmaT table
scalarField sigmaTtable_;

//-
Switch useInterpolatedSigmaT_;

// determin the row based on the relative velocity
label deflectionAngleRow(scalar cR) const;
void deflectionAngleRowBetween(Foam::scalar cR, Foam::label& rowA, Foam::label& rowB) const;

public:
// Constructor from dict

Expand All @@ -89,6 +94,7 @@ public:

PtrList<PtrList<AbInitioMatrix>> AImatrixs_;


public:

//- Runtime type information
Expand Down

0 comments on commit 705c2fb

Please sign in to comment.