Browse Source

Added -n flag to skip solving BVP

master
vyaas 2 years ago
parent
commit
87c7d5c20e
4 changed files with 33 additions and 24 deletions
  1. +1
    -1
      examples/BVP/methane_BVP.sh
  2. +4
    -4
      src/Makefile
  3. +27
    -18
      src/sensBVP.cpp
  4. +1
    -1
      src/sensBrute.cpp

+ 1
- 1
examples/BVP/methane_BVP.sh View File

@@ -1 +1 @@
sensBVP -r 1e-06 -a 1e-12 -f 1e-07 -T 900.0 -P 10.0 -m ./mech-FFCM1.cti -c CH4:0.0499002,O2:0.199601,N2:0.750499 -t 1 -s
sensBVP -r 1e-06 -a 1e-12 -f 1e-07 -T 900.0 -P 10.0 -m ffcm1.cti -c CH4:0.0499002,O2:0.199601,N2:0.750499 -t 1 -s -o

+ 4
- 4
src/Makefile View File

@@ -1,10 +1,10 @@
compiler =g++
CANTERA_DIR =/opt/scientific/cantera-2.4_gnu_blas
CVODE_DIR =/opt/scientific/sundials-5.1.0
KINSOL_DIR =/opt/scientific/sundials-5.1.0
CANTERA_DIR=/home/vyaas/.local
CVODE_DIR=/home/vyaas/.local
KINSOL_DIR=/home/vyaas/.local
BVPEXE =sensBVP
BRUTEEXE =sensBrute
DESTDIR =~/bin
DESTDIR =/home/vyaas/.local/bin

CANTERA_INCLUDES=-I$(CANTERA_DIR)/include
CVODE_INCLUDES =-I$(CVODE_DIR)/include


+ 27
- 18
src/sensBVP.cpp View File

@@ -24,7 +24,7 @@ Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <time.h>

/*Cantera include files*/
#include <cantera/IdealGasMix.h>
#include "IdealGasMix.h"

/*Sundials include files*/
#include <cvode/cvode.h> /* prototypes for CVODE fcts., consts. */
@@ -140,6 +140,7 @@ typedef struct {
bool IVPSuccess;
bool BVPSuccess;
bool sensSuccess;
bool solveBVP; //The BVP does not HAVE to be solved: use this flag to skip solving it!
int nsp,neq,npts,nvar; //key quantities required in for loops:
//nsp-> no: of chemical species
//neq-> number of governing equations
@@ -522,21 +523,23 @@ int main(int argc, char *argv[])
ier=KINSetPrintLevel(mem,2);

/* Solve the BVP! */
ier = KINSol(mem, /* KINSol memory block */
yp, /* initial guess on input; solution vector */
KIN_NONE,//KIN_LINESEARCH,/* global strategy choice */
scale, /* scaling vector, for the variable cc */
scale); /* scaling vector for function values fval */

if (check_flag(&ier, "KINSol", 1)){
data->BVPSuccess=false;
}else{
data->BVPSuccess=true;
/* Get scaled norm of the system function */
ier = KINGetFuncNorm(mem, &data->ftol);
//ier = check_flag(&ier, "KINGetfuncNorm", 1);
printf("\nComputed solution (||F|| = %g):\n\n",data->ftol);
printf("KinSOL Ignition Delay: %15.6es\n", taup(1));
if(data->solveBVP){
ier = KINSol(mem, /* KINSol memory block */
yp, /* initial guess on input; solution vector */
KIN_NONE,//KIN_LINESEARCH,/* global strategy choice */
scale, /* scaling vector, for the variable cc */
scale); /* scaling vector for function values fval */

if (check_flag(&ier, "KINSol", 1)){
data->BVPSuccess=false;
}else{
data->BVPSuccess=true;
/* Get scaled norm of the system function */
ier = KINGetFuncNorm(mem, &data->ftol);
//ier = check_flag(&ier, "KINGetfuncNorm", 1);
printf("\nComputed solution (||F|| = %g):\n\n",data->ftol);
printf("KinSOL Ignition Delay: %15.6es\n", taup(1));
}
}
//ier=check_flag(&ier, "KINSol", 1);

@@ -549,7 +552,7 @@ int main(int argc, char *argv[])

/********************************************************/
/*Begin sensitivity analysis here:*/
if(data->BVPSuccess){
if(data->BVPSuccess || !data->solveBVP){
/* Create banded SUNMatrix for use in linear solves; bandwidths
* are dictated by the dependence of the solution at a given
* time on one time-step ahead and one time-step behind:*/
@@ -777,6 +780,8 @@ static int parseInput(UserData data, int argc, char *argv[]){
data->TIgnFac=0.20;
/*Sorting*/
data->sort=false;
/* Solve two-point BVP: */
data->solveBVP=true;
/*****************************************************/

int ier;
@@ -785,7 +790,7 @@ static int parseInput(UserData data, int argc, char *argv[]){
char comp[BUFSIZE+1];
bool enteredT0, enteredP, enteredMech, enteredComp;
enteredT0=enteredP=enteredMech=enteredComp=false;
while((opt=getopt(argc,argv,"a:r:f:T:P:m:c:t:q:vsod")) != -1){
while((opt=getopt(argc,argv,"a:r:f:T:P:m:c:t:q:vsodn")) != -1){
switch(opt){
case 'a':
data->atol=RCONST(atof(optarg));
@@ -834,6 +839,9 @@ static int parseInput(UserData data, int argc, char *argv[]){
case 'q':
data->TIgnFac=RCONST(atof(optarg));
break;
case 'n':
data->solveBVP=false;
break;
default:
printInstructions();
return(-1);
@@ -1484,6 +1492,7 @@ static void printInstructions(){
printf("\n-d :Enables manual dPdt entryspecies sensitivity output\n");
printf("\n-o :Enables sorting of ignition delay sensitivity output\n");
printf("\n-q :factor that determines ignition temperature (default: 0.2)\n");
printf("\n-n :Disables the boundary value problem solver\n");
printf("\nexample: <executable> ");
printf("-T 1200.0 -P 1.0 -m gri30.cti");
printf(" -c H2:1.0,N2:3.76,O2:1.0");


+ 1
- 1
src/sensBrute.cpp View File

@@ -25,7 +25,7 @@ Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <time.h>

/*Cantera include files*/
#include <cantera/IdealGasMix.h>
#include "IdealGasMix.h"

/*Sundials include files*/
#include <cvode/cvode.h> /* prototypes for CVODE fcts., consts. */


Loading…
Cancel
Save