23 void HeatLoss::InputParam(
const HLoss& loss)
34 void HeatLoss::Setup(
const OCP_USI& nb)
49 void HeatLoss::CalHeatLoss(
const vector<USI>& location,
50 const vector<OCP_DBL>& T,
51 const vector<OCP_DBL>& lT,
52 const vector<OCP_DBL>& initT,
60 if (location[n] > 0) {
62 lambda = location[n] == 1 ?
obD :
ubD;
65 theta = T[n] - initT[n];
66 d = sqrt(lambda * t) / 2;
67 tmp = 3 * pow(d, 2) + lambda * dt;
68 p[n] = (theta * (lambda * dt / d) +
lI[n] -
69 dT * (pow(d, 3) / (lambda * dt))) /
71 pT[n] = (lambda * dt / d - pow(d, 3) / (lambda * dt)) / tmp;
72 q = (2 *
p[n] * d - theta + pow(d, 2) * dT / (lambda * dt)) /
74 I[n] = theta * d +
p[n] * pow(d, 2) + 2 * q * pow(d, 3);
80 void HeatLoss::ResetToLastTimeStep()
87 void HeatLoss::UpdateLastTimeStep()
121 InputParamBLKOIL(rs_param);
124 InputParamCOMPS(rs_param);
127 InputParamTHERMAL(rs_param);
130 InputSatFunc(rs_param);
208 switch (
flashCal[0]->GetMixtureType()) {
230 InputRockFunc(rs_param);
231 cout << endl <<
"BLACKOIL model is selected" << endl;
261 vector<vector<OCP_DBL>> temp;
264 temp[0].push_back(0);
265 temp[0].push_back(1E8);
267 temp[1].push_back(
rsTemp);
268 temp[1].push_back(
rsTemp);
290 InputRockFunc(rs_param);
291 cout << endl <<
"COMPOSITIONAL model is selected" << endl;
307 vector<vector<OCP_DBL>> temp;
310 temp[0].push_back(0);
311 temp[0].push_back(1E8);
313 temp[1].push_back(
rsTemp);
314 temp[1].push_back(
rsTemp);
348 InputRockFuncT(rs_param);
396 if (rs_param.
rockSet[i].type ==
"LINEAR") {
422 AllocateGridRockT(myGrid);
435 flow[i]->SetupOptionalFeatures(myGrid, optFeatures);
461 Zmin = Zmin < temp1 ? Zmin : temp1;
462 Zmax = Zmax > temp2 ? Zmax : temp2;
464 OCP_DBL tabdz = (Zmax - Zmin) / (tabrow - 1);
468 vector<OCP_DBL>& Ztmp = DepthP.
GetCol(0);
469 vector<OCP_DBL>& Potmp = DepthP.
GetCol(1);
470 vector<OCP_DBL>& Pgtmp = DepthP.
GetCol(2);
471 vector<OCP_DBL>& Pwtmp = DepthP.
GetCol(3);
473 vector<OCP_DBL> tmpInitZi(
numCom, 0);
477 for (
USI i = 1; i < tabrow; i++) {
478 Ztmp[i] = Ztmp[i - 1] + tabdz;
485 if (Dref <= Ztmp[0]) {
487 }
else if (Dref >= Ztmp[tabrow - 1]) {
488 beginId = tabrow - 1;
491 distance(Ztmp.begin(), find_if(Ztmp.begin(), Ztmp.end(),
492 [s = Dref](
auto& t) { return t > s; }));
498 OCP_DBL gammaOtmp, gammaWtmp, gammaGtmp;
512 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
513 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
514 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Dref, 1);
517 flashCal[0]->RhoPhase(Pgref, Pbb, myTemp, tmpInitZi.data(),
GAS);
518 Pbegin = Pgref + gammaGtmp * (Ztmp[beginId] - Dref);
519 Pgtmp[beginId] = Pbegin;
522 for (
USI id = beginId;
id > 0;
id--) {
523 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
524 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
525 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
528 tmpInitZi.data(),
GAS);
529 Pgtmp[
id - 1] = Pgtmp[id] - gammaGtmp * (Ztmp[id] - Ztmp[
id - 1]);
532 for (
USI id = beginId;
id < tabrow - 1;
id++) {
533 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
534 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
535 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
538 tmpInitZi.data(),
GAS);
539 Pgtmp[
id + 1] = Pgtmp[id] + gammaGtmp * (Ztmp[
id + 1] - Ztmp[id]);
545 mydz = (DOGC - Dref) / mynum;
548 for (
USI i = 0; i < mynum; i++) {
549 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
550 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
551 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
554 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
GAS);
555 Ptmp += gammaGtmp * mydz;
559 for (
USI i = 0; i < mynum; i++) {
560 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
561 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
562 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
565 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
OIL);
566 Ptmp -= gammaOtmp * mydz;
572 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
573 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
574 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Dref, 1);
577 flashCal[0]->RhoPhase(Poref, Pbb, myTemp, tmpInitZi.data(),
OIL);
578 Pbegin = Poref + gammaOtmp * (Ztmp[beginId] - Dref);
579 Potmp[beginId] = Pbegin;
581 for (
USI id = beginId;
id > 0;
id--) {
582 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
583 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
584 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
587 tmpInitZi.data(),
OIL);
588 Potmp[
id - 1] = Potmp[id] - gammaOtmp * (Ztmp[id] - Ztmp[
id - 1]);
591 for (
USI id = beginId;
id < tabrow - 1;
id++) {
592 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
593 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
594 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
597 tmpInitZi.data(),
OIL);
598 Potmp[
id + 1] = Potmp[id] + gammaOtmp * (Ztmp[
id + 1] - Ztmp[id]);
604 mydz = (DOWC - Dref) / mynum;
607 for (
USI i = 0; i < mynum; i++) {
608 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
609 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
610 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
613 tmpInitZi.data(),
OIL);
614 Ptmp += gammaOtmp * mydz;
618 for (
USI i = 0; i < mynum; i++) {
619 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
620 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
623 tmpInitZi.data(),
WATER);
624 Ptmp -= gammaWtmp * mydz;
630 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
631 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
634 flashCal[0]->RhoPhase(Pwref, Pbb, myTemp, tmpInitZi.data(),
WATER);
635 Pbegin = Pwref + gammaWtmp * (Ztmp[beginId] - Dref);
636 Pwtmp[beginId] = Pbegin;
638 for (
USI id = beginId;
id > 0;
id--) {
639 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
640 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
643 tmpInitZi.data(),
WATER);
644 Pwtmp[
id - 1] = Pwtmp[id] - gammaWtmp * (Ztmp[id] - Ztmp[
id - 1]);
647 for (
USI id = beginId;
id < tabrow - 1;
id++) {
648 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
649 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
652 tmpInitZi.data(),
WATER);
653 Pwtmp[
id + 1] = Pwtmp[id] + gammaWtmp * (Ztmp[
id + 1] - Ztmp[id]);
655 }
else if (Dref > DOWC) {
658 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
659 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
663 flashCal[0]->RhoPhase(Pwref, Pbb, myTemp, tmpInitZi.data(),
WATER);
664 Pbegin = Pwref + gammaWtmp * (Ztmp[beginId] - Dref);
665 Pwtmp[beginId] = Pbegin;
668 for (
USI id = beginId;
id > 0;
id--) {
669 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
670 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
673 tmpInitZi.data(),
WATER);
674 Pwtmp[
id - 1] = Pwtmp[id] - gammaWtmp * (Ztmp[id] - Ztmp[
id - 1]);
676 for (
USI id = beginId;
id < tabrow - 1;
id++) {
677 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
678 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
681 tmpInitZi.data(),
WATER);
682 Pwtmp[
id + 1] = Pwtmp[id] + gammaWtmp * (Ztmp[
id + 1] - Ztmp[id]);
688 mydz = (DOWC - Dref) / mynum;
691 for (
USI i = 0; i < mynum; i++) {
692 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
693 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
696 tmpInitZi.data(),
WATER);
697 Ptmp += gammaWtmp * mydz;
702 for (
USI i = 0; i < mynum; i++) {
703 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
704 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
705 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
708 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
OIL);
709 Ptmp -= gammaOtmp * mydz;
715 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
716 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
717 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Dref, 1);
720 flashCal[0]->RhoPhase(Poref, Pbb, myTemp, tmpInitZi.data(),
OIL);
721 Pbegin = Poref + gammaOtmp * (Ztmp[beginId] - Dref);
722 Potmp[beginId] = Pbegin;
724 for (
USI id = beginId;
id > 0;
id--) {
725 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
726 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
727 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
730 tmpInitZi.data(),
OIL);
731 Potmp[
id - 1] = Potmp[id] - gammaOtmp * (Ztmp[id] - Ztmp[
id - 1]);
734 for (
USI id = beginId;
id < tabrow - 1;
id++) {
735 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
736 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
737 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
740 tmpInitZi.data(),
OIL);
741 Potmp[
id + 1] = Potmp[id] + gammaOtmp * (Ztmp[
id + 1] - Ztmp[id]);
748 mydz = (DOGC - Dref) / mynum;
751 for (
USI i = 0; i < mynum; i++) {
752 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
753 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
754 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
758 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
OIL);
759 Ptmp += gammaOtmp * mydz;
763 for (
USI i = 0; i < mynum; i++) {
764 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
765 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
766 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
770 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
GAS);
771 Ptmp -= gammaGtmp * mydz;
777 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
778 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
779 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Dref, 1);
782 tmpInitZi.data(),
GAS);
783 Pbegin = Pgref + gammaGtmp * (Ztmp[beginId] - Dref);
784 Pgtmp[beginId] = Pbegin;
786 for (
USI id = beginId;
id > 0;
id--) {
787 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
788 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
789 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
793 tmpInitZi.data(),
GAS);
794 Pgtmp[
id - 1] = Pgtmp[id] - gammaGtmp * (Ztmp[id] - Ztmp[
id - 1]);
796 for (
USI id = beginId;
id < tabrow - 1;
id++) {
797 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
798 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
799 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
803 tmpInitZi.data(),
GAS);
804 Pgtmp[
id + 1] = Pgtmp[id] + gammaGtmp * (Ztmp[
id + 1] - Ztmp[id]);
812 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
813 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
814 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Dref, 1);
817 flashCal[0]->RhoPhase(Poref, Pbb, myTemp, tmpInitZi.data(),
OIL);
818 Pbegin = Poref + gammaOtmp * (Ztmp[beginId] - Dref);
819 Potmp[beginId] = Pbegin;
822 for (
USI id = beginId;
id > 0;
id--) {
823 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
824 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
825 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
828 tmpInitZi.data(),
OIL);
829 Potmp[
id - 1] = Potmp[id] - gammaOtmp * (Ztmp[id] - Ztmp[
id - 1]);
831 for (
USI id = beginId;
id < tabrow - 1;
id++) {
832 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
833 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
834 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
837 tmpInitZi.data(),
OIL);
838 Potmp[
id + 1] = Potmp[id] + gammaOtmp * (Ztmp[
id + 1] - Ztmp[id]);
845 mydz = (DOGC - Dref) / mynum;
848 for (
USI i = 0; i < mynum; i++) {
849 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
850 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
851 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
855 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
OIL);
856 Ptmp += gammaOtmp * mydz;
860 for (
USI i = 0; i < mynum; i++) {
861 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
862 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
863 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
867 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
GAS);
868 Ptmp -= gammaGtmp * mydz;
874 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
875 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
876 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Dref, 1);
879 tmpInitZi.data(),
GAS);
880 Pbegin = Pgref + gammaGtmp * (Ztmp[beginId] - Dref);
881 Pgtmp[beginId] = Pbegin;
883 for (
USI id = beginId;
id > 0;
id--) {
884 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
885 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
886 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
890 tmpInitZi.data(),
GAS);
891 Pgtmp[
id - 1] = Pgtmp[id] - gammaGtmp * (Ztmp[id] - Ztmp[
id - 1]);
894 for (
USI id = beginId;
id < tabrow - 1;
id++) {
895 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
896 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
897 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, Ztmp[
id], 1);
901 tmpInitZi.data(),
GAS);
902 Pgtmp[
id + 1] = Pgtmp[id] + gammaGtmp * (Ztmp[
id + 1] - Ztmp[id]);
909 mydz = (DOWC - Dref) / mynum;
912 for (
USI i = 0; i < mynum; i++) {
913 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
914 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
915 if (PBVD_flag) Pbb =
EQUIL.PBVD.
Eval(0, myz, 1);
918 flashCal[0]->RhoPhase(Ptmp, Pbb, myTemp, tmpInitZi.data(),
OIL);
919 Ptmp += gammaOtmp * mydz;
923 for (
USI i = 0; i < mynum; i++) {
924 if (initZi_flag)
initZi_Tab[0].Eval_All0(myz, tmpInitZi);
925 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, myz, 1);
928 tmpInitZi.data(),
WATER);
929 Ptmp -= gammaWtmp * mydz;
935 if (initZi_flag)
initZi_Tab[0].Eval_All0(Dref, tmpInitZi);
936 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Dref, 1);
939 flashCal[0]->RhoPhase(Pwref, Pbb, myTemp, tmpInitZi.data(),
WATER);
940 Pbegin = Pwref + gammaWtmp * (Ztmp[beginId] - Dref);
941 Pwtmp[beginId] = Pbegin;
943 for (
USI id = beginId;
id > 0;
id--) {
944 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
945 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
948 tmpInitZi.data(),
WATER);
949 Pwtmp[
id - 1] = Pwtmp[id] - gammaWtmp * (Ztmp[id] - Ztmp[
id - 1]);
952 for (
USI id = beginId;
id < tabrow - 1;
id++) {
953 if (initZi_flag)
initZi_Tab[0].Eval_All0(Ztmp[
id], tmpInitZi);
954 if (initT_flag) myTemp =
initT_Tab[0].Eval(0, Ztmp[
id], 1);
957 tmpInitZi.data(),
WATER);
958 Pwtmp[
id + 1] = Pwtmp[id] + gammaWtmp * (Ztmp[
id + 1] - Ztmp[id]);
965 std::vector<OCP_DBL> data(4, 0), cdata(4, 0);
967 vector<OCP_BOOL> FlagPcow(
NTSFUN, OCP_TRUE);
971 FlagPcow[i] = OCP_FALSE;
1006 if (1 - Sw <
TINY) {
1009 }
else if (1 - Sg <
TINY) {
1012 }
else if (1 - Sw - Sg <
TINY) {
1018 if (
depth[n] < DOGC) {
1020 }
else if (PBVD_flag) {
1027 if (!FlagPcow[
SATNUM[n]]) {
1037 for (
USI k = 0; k < ncut; k++) {
1041 DepthP.
Eval_All(0, dep, data, cdata);
1052 if (tmpSw + tmpSg > 1) {
1134 dx[bIda] = myGrid.
dx[bId];
1135 dy[bIda] = myGrid.
dy[bId];
1136 dz[bIda] = myGrid.
dz[bId];
1137 v[bIda] = myGrid.
v[bId];
1140 ntg[bIda] = myGrid.
ntg[bId];
1148 void Bulk::AllocateGridRockT(
const Grid& myGrid)
1169 dx[bIda] = myGrid.
dx[bId];
1170 dy[bIda] = myGrid.
dy[bId];
1171 dz[bIda] = myGrid.
dz[bId];
1172 v[bIda] = myGrid.
v[bId];
1175 ntg[bIda] = myGrid.
ntg[bId];
1211 OCP_ABORT(
"Number of phases is out of range!");
1224 Ttmp +=
T[n] *
v[n];
1239 for (
USI n = 0; n < len; n++) {
1256 std::ostringstream PStringSci;
1257 PStringSci << std::scientific <<
P[n];
1258 OCP_WARNING(
"Negative pressure: P[" + std::to_string(n) +
1259 "] = " + PStringSci.str());
1260 cout <<
"P = " <<
P[n] << endl;
1261 return BULK_NEGATIVE_PRESSURE;
1265 return BULK_SUCCESS;
1272 std::ostringstream PStringSci;
1273 PStringSci << std::scientific <<
T[n];
1274 OCP_WARNING(
"Negative pressure: T[" + std::to_string(n) +
1275 "] = " + PStringSci.str());
1276 cout <<
"T = " <<
T[n] << endl;
1277 return BULK_NEGATIVE_TEMPERATURE;
1281 return BULK_SUCCESS;
1290 for (
OCP_USI n = 0; n < len; n++) {
1293 if (
Ni[n] > -1E-3 *
Nt[bId] && OCP_FALSE) {
1294 Ni[n] = 1E-8 *
Nt[bId];
1297 std::ostringstream NiStringSci;
1298 NiStringSci << std::scientific <<
Ni[n];
1299 OCP_WARNING(
"Negative Ni: Ni[" + std::to_string(cId) +
"] in Bulk[" +
1300 std::to_string(bId) +
"] = " + NiStringSci.str() +
", " +
1301 "dNi = " + std::to_string(
dNNR[n]));
1303 return BULK_NEGATIVE_COMPONENTS_MOLES;
1307 return BULK_SUCCESS;
1319 cout <<
"Volume error at Bulk[" << n <<
"] = " << setprecision(6) << dVe
1320 <<
" is too big!" << endl;
1321 return BULK_OUTRANGED_VOLUME_ERROR;
1324 return BULK_SUCCESS;
1330 return BULK_OUTRANGED_CFL;
1332 return BULK_SUCCESS;
1350 tmp = fabs(
P[n] -
lP[n]);
1356 tmp = fabs(
T[n] -
lT[n]);
1364 tmp = fabs(
S[
id] -
lS[
id]);
1373 tmp = fabs(max(
Ni[
id],
lNi[
id]));
1375 tmp = fabs(
Ni[
id] -
lNi[
id]) / tmp;
1394 void Bulk::AllocateError()
1411 if (bulkTypeAIM.IfFIMbulk(n)) {
1413 cout << setw(6) << n <<
" ";
1417 if ((iter + 1) % 10 == 0) {
const OCP_DBL TINY
Small constant.
const USI PHASE_ODGW01
Phase type = oil-dry gas-water.
unsigned int USI
Generic unsigned integer.
const USI GAS
Fluid type = gas.
double OCP_DBL
Double precision.
const OCP_DBL GRAVITY_FACTOR
0.00694444 ft2 psi / lb
const USI BLKOIL_DOGW
black oil model with dead oil, dry gas, water
const USI WATER
Fluid type = water.
const USI PHASE_ODGW
Phase type = oil-dry gas-water.
const USI PHASE_ODGW02
Phase type = oil-dry gas-water.
const USI BLKOIL_OW
black oil model with oil and water
const USI OIL
Fluid type = oil.
const USI BLKOIL_OG
black oil model with oil and gas
const USI BLKOIL_ODGW
black oil model with live oil, dry gas, water
const USI PHASE_W
Phase type = water only.
unsigned int OCP_USI
Long unsigned integer.
const USI PHASE_ODGW01_MISCIBLE
Phase type = oil-dry gas-water.
const USI PHASE_OW
Phase type = oil-water.
const USI PHASE_DOGW
Phase type = dead oil-gas-water.
unsigned int OCP_BOOL
OCP_BOOL in OCP.
const USI BLKOIL_W
black oil model only with water
#define OCP_FUNCNAME
Print Function Name.
#define OCP_WARNING(msg)
Log warning messages.
#define OCP_ABORT(msg)
Abort if critical error happens.
void SetupOptionalFeatures(const Grid &myGrid, OptionalFeatures &optFeatures)
Setup optional features.
vector< OCP_DBL > dNNR
Ni change between NR steps.
vector< OCP_DBL > lP
last P
vector< OCP_DBL > lS
last S
vector< Rock * > rock
rock model
vector< FlowUnit * > flow
Vector for capillary pressure, relative perm.
USI NTSFUN
num of SAT regions
USI numPhase
Number of phase.
vector< OCP_DBL > T
Temperature: numBulk.
vector< OCP_DBL > S
Saturation of phase: numPhase*numBulk.
OCP_BOOL oil
If OCP_TRUE, oil phase could exist.
vector< USI > bLocation
Location of bulk: top, bottom, side.
OCP_BOOL ifComps
If OCP_TRUE, compositional model will be used.
OCP_DBL dSmax
Max change in saturation during the current time step.
void SetupBulkType(const Grid &myGrid)
Setup Bulk type.
vector< OCP_DBL > ntg
net to gross of bulk.
vector< OCP_DBL > dy
Size of cell in y-direction: activeGridNum.
vector< USI > PVTNUM
Identify PVT region in black-oil model: numBulk.
OCP_BOOL gas
If OCP_TRUE, gas phase could exist.
OCP_DBL maxCFL
max CFL number
USI NTROCC
num of Rock regions
vector< USI > SATNUM
Identify SAT region: numBulk.
vector< OCP_DBL > depth
Depth of center of grid cells: activeGridNum.
vector< OCP_DBL > rockVp
pore volume = Vgrid * ntg * poro.
vector< OCP_DBL > Ni
Moles of component: numCom*numBulk.
USI SATmode
Identify SAT mode.
void CalMaxChange()
Calculate max change of indicator variables.
vector< OCP_DBL > ePEC
error for fugacity balance equations, EoS only now
USI NTPVT
num of PVT regions
vector< OCP_DBL > dSNR
saturation change between NR steps
HeatLoss hLoss
Heat loss iterm.
OCP_BOOL ifThermal
Id OCP_TRUE, ifThermal model will be used.
OCP_INT CheckNi()
Check if negative Ni occurs.
vector< OCP_DBL > Nt
Total moles of components in bulks: numBulk.
vector< OCP_DBL > dz
Size of cell in z-direction: activeGridNum.
OCP_INT CheckT() const
Check if negative T occurs.
vector< OCP_DBL > thconr
Rock ifThermal conductivity: activeGridNum.
void AllocateRegion(const Grid &myGrid)
Allocate memory for region num.
vector< OCP_DBL > lT
last T
vector< Mixture * > flashCal
Flash calculation class.
void InputParam(const ParamReservoir &rs_param)
Input param from internal data structure ParamReservoir.
vector< USI > phase2Index
Location of phase according to its name: numPhase.
vector< OCPTable > initZi_Tab
Initial mole ratio of components vs. depth, table set.
vector< vector< OCP_DBL > > satcm
critical saturation when phase becomes mobile / immobile.
OCP_DBL CalNRdSmax(OCP_USI &index)
Calculate some auxiliary variable, for example, dSmax.
vector< OCP_DBL > vf
Total fluid volume: numBulk.
vector< OCP_DBL > rockKz
current rock permeability along the z direction.
OCP_DBL CalFTR() const
Calculate average Temperature in reservoir.
ParamEQUIL EQUIL
Initial Equilibration.
OCP_BOOL ifUseEoS
If OCP_TRUE, then EoS model is used.
vector< OCPTable > initT_Tab
Initial temperature vs. depth, table set.
OCP_DBL dNmax
Max change in moles of component during the current time step.
vector< OCP_DBL > rockKx
current rock permeability along the x direction.
OCP_DBL NRdSmax
Max saturation difference in an NR step(Real)
OCP_DBL rsTemp
Reservoir temperature.
vector< USI > bType
Indicate bulk type, 0: rock, 1: rock and fluid.
void ShowFIMBulk(const OCP_BOOL &flag=OCP_FALSE) const
Print Bulk which are implicit.
void SetupIsoT(const Grid &myGrid)
Allocate memory for fluid grid for isothermal model.
USI PVTmodeB
Identify PVT mode in black-oil model.
vector< OCP_DBL > rockKy
current rock permeability along the y direction.
OCP_BOOL disGas
If OCP_TRUE, dissolve gas in live oil could exist.
OCP_DBL dTmax
Max change in temperature during the current time step.
OCP_INT CheckP() const
Check if negative P occurs.
OCP_BOOL water
If OCP_TRUE, water phase could exist.
vector< OCP_DBL > Pb
Bubble point pressure: numBulk.
void SetupT(const Grid &myGrid)
Allocate memory for fluid grid for ifThermal model.
vector< OCP_DBL > v
Volume of grids: activeGridNum.
USI numComH
Number of HydroCarbon.
void InitPTSw(const USI &tabrow)
Calculate initial equilibrium – hydrostatic equilibration.
OCP_BOOL ifBlackOil
If OCP_TRUE, black-oil model will be used.
OCP_DBL CalFPR() const
Calculate average pressure in reservoir.
OCP_USI numBulk
Number of bulks (active grids).
OCP_INT CheckVe(const OCP_DBL &Vlim) const
Check if relative volume error is outranged.
vector< OCP_DBL > poroInit
initial rock porosity * ntg.
vector< OCP_DBL > thconp
Phase thermal conductivity: numPhase.
vector< USI > ROCKNUM
index of Rock table for each bulk
vector< OCP_DBL > dx
Size of cell in x-direction: activeGridNum.
vector< OCP_DBL > initT
Initial temperature of each bulk: numBulk.
OCP_INT CheckCFL(const OCP_DBL &cflLim) const
Check if Cfl is outranged.
vector< OCP_DBL > P
Pressure: numBulk.
vector< OCP_DBL > lNi
last Ni
void AllocateGridRockIsoT(const Grid &myGrid)
Allocate memory for Rock properties.
USI numCom
Number of component.
OCP_DBL dPmax
Max change in pressure during the current time step.
USI numPhase
num of phase, water is excluded, constant now.
USI numCom
num of components, water is excluded.
vector< OCP_DBL > ky
Absolute permeability in y-direction: numGrid.
vector< OCP_DBL > v
Volume of cells: numGrid.
vector< OCP_USI > map_Act2All
Mapping from active grid to all grid: activeGridNum.
vector< USI > ROCKNUM
index of rock table for each grid: numGrid
OCP_USI activeGridNum
Num of active grid.
vector< USI > PVTNUM
Identify PVT region for the blackoil model: numGrid.
vector< OCP_DBL > depth
Depth of center of grid cells: numGrid.
vector< USI > SATNUM
Identify SAT region: numGrid.
vector< OCP_DBL > kz
Absolute permeability in z-direction: numGrid.
vector< USI > gLocation
Top face, bottom face, side face, numGrid.
vector< OCP_DBL > dz
Size of cell in z-direction: numGrid.
vector< GB_Pair > map_All2Flu
Mapping from all grid to fluid grid: numGrid.
vector< OCP_DBL > thconr
Rock if Thermal conductivity: numGrid.
vector< OCP_DBL > poro
Initial porosity of rock cells: numGrid.
vector< OCP_DBL > dy
Size of cell in y-direction: numGrid.
vector< GB_Pair > map_All2Act
Mapping from grid to active all grid: numGrid.
vector< OCP_DBL > dx
Size of cell in x-direction: numGrid.
OCP_USI numGrid
Number of all cells.
vector< OCP_DBL > ntg
Net to gross ratio of cells: numGrid.
vector< OCP_DBL > kx
Absolute permeability in x-direction: numGrid.
OCP_DBL obC
Volumetric heat capacity of overburden rock.
OCP_BOOL ifHLoss
If use Heat loss.
OCP_DBL obK
Thermal conductivity of overburden rock.
OCP_DBL ubK
Thermal conductivity of underburden rock.
OCP_DBL ubC
Volumetric heat capacity of underburden rock.
vector< OCP_DBL > pT
dP / dT
OCP_DBL ubD
Thermal diffusivity of underburden rock.
OCP_DBL ubK
Thermal conductivity of underburden rock.
vector< OCP_DBL > p
Auxiliary variable.
OCP_DBL obC
Volumetric heat capacity of overburden rock.
OCP_DBL obD
Thermal diffusivity of overburden rock.
vector< OCP_DBL > lpT
last pT
OCP_DBL obK
Thermal conductivity of overburden rock.
vector< OCP_DBL > I
Auxiliary variable.
vector< OCP_DBL > lp
Auxiliary variable.
OCP_BOOL ifHLoss
If use Heat loss.
vector< OCP_DBL > lI
Auxiliary variable.
OCP_USI numBulk
Num of Bulk.
OCP_DBL ubC
Volumetric heat capacity of underburden rock.
USI Eval_All(const USI &j, const OCP_DBL &val, vector< OCP_DBL > &outdata, vector< OCP_DBL > &slope)
Careful: the memory outdata and slope have not be allocated before.
void Display() const
Display the data of table on screen.
void Setup(const vector< vector< OCP_DBL >> &src)
Setup tables from existing data of table.
vector< OCP_DBL > & GetCol(const USI &j)
return the jth column in table to modify or use.
OCP_BOOL IsEmpty() const
judge if table is empty.
OCP_DBL Eval(const USI &j, const OCP_DBL &val, const USI &destj)
vector< RockParam > rockSet
a set of rock
OCP_BOOL oil
If OCP_TRUE, oil phase could exist.
USI NTSFUN
Num of SAT regions.
USI NTROOC
Num of Rock regions.
TableSet ZMFVD_T
Table set of ZMFVD.
vector< OCP_DBL > EQUIL
See ParamEQUIL.
ComponentParam comsParam
information for components
OCP_DBL thconw
water ifThermal conductivity
OCP_BOOL gas
If OCP_TRUE, gas phase could exist.
TableSet SOF3_T
Table set of SOF3.
TableSet PBVD_T
Table set of PBVD.
OCP_BOOL comps
If OCP_TRUE, compositional model will be used.
TableSet TEMPVD_T
Table set of TEMPVD.
OCP_DBL thcong
gas ifThermal conductivity
OCP_BOOL blackOil
If ture, blackoil model will be used.
OCP_BOOL disGas
If OCP_TRUE, dissolve gas could exist in oil phase.
HLoss hLoss
Heat loss property.
OCP_DBL thcono
oil ifThermal conductivity
USI NTPVT
Num of PVT regions.
OCP_DBL rsTemp
Temperature for reservoir.
OCP_BOOL water
If OCP_TRUE, water phase could exist.
OCP_BOOL thermal
If OCP_TRUE, ifThermal model will be used.
vector< vector< vector< OCP_DBL > > > data
All table with the same name.