diff --git a/Code/Source/.vscode/settings.json b/Code/Source/.vscode/settings.json new file mode 100644 index 0000000..0c83701 --- /dev/null +++ b/Code/Source/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "iostream": "cpp", + "ostream": "cpp" + } +} \ No newline at end of file diff --git a/Code/Source/cvOneDBFSolver.cxx b/Code/Source/cvOneDBFSolver.cxx index 9fbc2c6..8c12cca 100644 --- a/Code/Source/cvOneDBFSolver.cxx +++ b/Code/Source/cvOneDBFSolver.cxx @@ -1119,6 +1119,8 @@ void cvOneDBFSolver::QuerryModelInformation(void) jointList.push_back(feajoint); } + cout << "Line 1122" << endl; + // Loop on Segments long temp = 0; for (i=0; iSetDensity(density); olfmat->SetDynamicViscosity(dynamicViscosity); olfmat->SetProfileExponent(profile_exponent); olfmat->SetReferencePressure(pRef); + olfmat->SetHydraulicConductivity(L_P); + olfmat->SetStarlingAmbientPressure(P_ambient); olfmat->SetMaterialType(params,pRef); printf("new cvOneMaterialOlufsen called check pRef %f \n", olfmat->GetReferencePressure()); return cvOneDGlobal::gMaterialManager->AddNewMaterial(MaterialType_MATERIAL_OLUFSEN,(cvOneDMaterial*)olfmat); } int cvOneDMaterialManager::AddNewMaterialLinear(double density, double dynamicViscosity, - double profile_exponent, double pRef, - double EHR){ + double profile_exponent, double pRef, double L_P, + double P_ambient, double EHR){ cvOneDMaterialLinear* linearmat = new cvOneDMaterialLinear(); linearmat->SetDensity(density); linearmat->SetDynamicViscosity(dynamicViscosity); linearmat->SetProfileExponent(profile_exponent); linearmat->SetReferencePressure(pRef); linearmat->SetEHR(EHR,pRef); + linearmat->SetHydraulicConductivity(L_P); + linearmat->SetStarlingAmbientPressure(P_ambient); return cvOneDGlobal::gMaterialManager->AddNewMaterial(MaterialType_MATERIAL_LINEAR,(cvOneDMaterial*)linearmat); } @@ -88,6 +92,7 @@ cvOneDMaterial* cvOneDMaterialManager::GetNewInstance(int matID){ // printf("In GetNewInstance cvOneDMaterialOlufsen is called matID=%i \n",matID); *olfmat = *((cvOneDMaterialOlufsen*)(materials[matID])); // printf("In GetNewInstance cvOneDMaterialOlufsen* materials is called \n"); + olfmat->GetStarlingAmbientPressure(); return (cvOneDMaterial*)olfmat; }else if (types[matID] == MaterialType_MATERIAL_LINEAR) { cvOneDMaterialLinear* linearmat = new cvOneDMaterialLinear(); diff --git a/Code/Source/cvOneDMaterialManager.h b/Code/Source/cvOneDMaterialManager.h index 03365f6..02fa97f 100644 --- a/Code/Source/cvOneDMaterialManager.h +++ b/Code/Source/cvOneDMaterialManager.h @@ -45,10 +45,12 @@ class cvOneDMaterialManager{ int AddNewMaterial(MaterialType type, cvOneDMaterial* mat); int AddNewMaterialOlufsen(double density, double dynamicViscosity, - double profile_exponent, double pRef, double *params); + double profile_exponent, double pRef, + double L_P, double P_ambient, double *params); int AddNewMaterialLinear(double density, double dynamicViscosity, - double profile_exponent, double pRef, double EHR); + double profile_exponent, double pRef, + double L_P, double P_ambient, double EHR); // caller must deallocate material instance to avoid memory leak cvOneDMaterial* GetNewInstance(int matID); diff --git a/Code/Source/cvOneDMaterialOlufsen.cxx b/Code/Source/cvOneDMaterialOlufsen.cxx index c0106f7..85431a3 100644 --- a/Code/Source/cvOneDMaterialOlufsen.cxx +++ b/Code/Source/cvOneDMaterialOlufsen.cxx @@ -63,35 +63,37 @@ cvOneDMaterialOlufsen::cvOneDMaterialOlufsen(){ // printf("call cvOneMaterialsOlufsen p1_=%f K3_=%f \n",p1_,K3_); } -cvOneDMaterialOlufsen::~cvOneDMaterialOlufsen(){ -} +cvOneDMaterialOlufsen::~cvOneDMaterialOlufsen(){} cvOneDMaterialOlufsen::cvOneDMaterialOlufsen (const cvOneDMaterialOlufsen &rhs){ // this seems not used cvOneDMaterial::operator=(rhs); double k1 = 0,k2 = 0,k3 = 0; - double pref=0; - rhs.GetParams( &k1, &k2, &k3, &pref); + double pref=0; double P_amb_ref=0; double L_P_ref = 0; + rhs.GetParams( &k1, &k2, &k3, &pref, &P_amb_ref, &L_P_ref); K1_ = k1; K2_ = k2; K3_ = k3; p1_= pref; + P_ambient = P_amb_ref; + L_P = L_P_ref; // printf("call cvOneDmaterialOlufsen &rhs\n"); } - cvOneDMaterialOlufsen& cvOneDMaterialOlufsen::operator= (const cvOneDMaterialOlufsen &that){ if (this != &that) { cvOneDMaterial::operator=(that); double k1 = 0,k2 = 0,k3 = 0; - double pref=0; - that.GetParams( &k1, &k2, &k3, &pref); + double pref=0; double P_amb_ref=0; double L_P_ref = 0; + that.GetParams( &k1, &k2, &k3, &pref, &P_amb_ref, &L_P_ref); K1_ = k1; K2_ = k2; K3_ = k3; p1_= pref; + P_ambient = P_amb_ref; + L_P = L_P_ref; // printf("call cvOneDMaterialOlufsen that this K3_=%f p1_=%f \n",K3_,p1_ ); } return *this; @@ -102,8 +104,8 @@ void cvOneDMaterialOlufsen::SetMaterialType(double *mType,double Pref){ K2_ = mType[1]; K3_ = mType[2]; PP1_=Pref; - cout<< "Setting material K's "<< K1_ <<" "<< K2_<<" "<< K3_<< " ..." << endl; - cout<< "Setting reference Pressure "<< PP1_<AddNewMaterialOlufsen(density,dynamicViscosity, - profile_exponent,pRef,params); + profile_exponent,pRef,L_P,P_ambient,params); return CV_OK; }else if(!strcmp (MaterialTypeString, "MATERIAL_LINEAR")){ double EHR = params[0]; *matID = cvOneDGlobal::gMaterialManager->AddNewMaterialLinear(density,dynamicViscosity, - profile_exponent,pRef,EHR); + profile_exponent,pRef,L_P,P_ambient,EHR); return CV_OK; }else{ return CV_ERROR; diff --git a/Code/Source/cvOneDModelManager.h b/Code/Source/cvOneDModelManager.h index 152dc2a..58da64c 100644 --- a/Code/Source/cvOneDModelManager.h +++ b/Code/Source/cvOneDModelManager.h @@ -51,7 +51,8 @@ class cvOneDModelManager{ int CreateMaterial(char *matName, char *MaterialTypeString, double density, double dynamicViscosity, double profile_exponent, double pRef, - int numParams, double *params, int *matID); + double L_P, double P_ambient, int numParams, + double *params, int *matID); // CREATE SEGMENT int CreateSegment(char* segName,long segID, double segLen, diff --git a/Code/Source/cvOneDMthSegmentModel.cxx b/Code/Source/cvOneDMthSegmentModel.cxx index cf13e87..e8de99f 100644 --- a/Code/Source/cvOneDMthSegmentModel.cxx +++ b/Code/Source/cvOneDMthSegmentModel.cxx @@ -109,8 +109,9 @@ void cvOneDMthSegmentModel::N_MinorLoss(long ith, double* N_vec){ // set defaults N_vec[0] = sub->GetMaterial()->GetN(S[1]); - for (int i=1; i<5; i++) + for (int i=1; i<5; i++) { N_vec[i] = 0.0; + } if(minorLoss == MinorLossScope::NONE ){//|| minorLoss != MinorLossScope::STENOSIS ){ return; @@ -200,7 +201,6 @@ void cvOneDMthSegmentModel::N_MinorLoss(long ith, double* N_vec){ N_vec[0] = std; } - // cout << " -N " << -N << " Q(1) :"<< Q[1] << endl; } diff --git a/Code/Source/cvOneDOptions.h b/Code/Source/cvOneDOptions.h index 7f8ace7..95609bb 100644 --- a/Code/Source/cvOneDOptions.h +++ b/Code/Source/cvOneDOptions.h @@ -80,6 +80,8 @@ class cvOneDOptions{ cvDoubleVec materialViscosity; cvDoubleVec materialPRef; cvDoubleVec materialExponent; + cvDoubleVec materialHydraulicConductivity; + cvDoubleVec materialAmbientPressure; cvDoubleVec materialParam1; cvDoubleVec materialParam2; cvDoubleVec materialParam3; diff --git a/Code/Source/cvOneDSolverDefinitions.h b/Code/Source/cvOneDSolverDefinitions.h index 5cd18d0..7ad2964 100644 --- a/Code/Source/cvOneDSolverDefinitions.h +++ b/Code/Source/cvOneDSolverDefinitions.h @@ -29,20 +29,20 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CVONEDSOLVERDEFINITIONS_H -#define CVONEDSOLVERDEFINITIONS_H - - -// -// cvOneDSolverDefinitions.h - Some definitions used throughout the solver -// - -#define MAX_STRING_SIZE 20 -#define EPSILON 1.0e-10 -#define OUTPUT_PRECISION 12 -#define MAX_NONLINEAR_ITERATIONS 30 -#define RELATIVE_TOLERANCE 1.0e-7 -#define ABSOLUTE_TOLERANCE 5.0e-6 - -#endif // CVONEDSOLVERDEFINITIONS_H - +#ifndef CVONEDSOLVERDEFINITIONS_H +#define CVONEDSOLVERDEFINITIONS_H + + +// +// cvOneDSolverDefinitions.h - Some definitions used throughout the solver +// + +#define MAX_STRING_SIZE 20 +#define EPSILON 1.0e-10 +#define OUTPUT_PRECISION 12 +#define MAX_NONLINEAR_ITERATIONS 100 +#define RELATIVE_TOLERANCE 1.0e-7 +#define ABSOLUTE_TOLERANCE 5.0e-6 + +#endif // CVONEDSOLVERDEFINITIONS_H + diff --git a/Code/Source/main.cxx b/Code/Source/main.cxx index c82cb7d..4a81826 100644 --- a/Code/Source/main.cxx +++ b/Code/Source/main.cxx @@ -175,6 +175,8 @@ void createAndRunModel(cvOneDOptions* opts){ opts->materialViscosity[loopA], opts->materialExponent[loopA], opts->materialPRef[loopA], + opts->materialHydraulicConductivity[loopA], + opts->materialAmbientPressure[loopA], numParams, doubleParams, &matID); if(matError == CV_ERROR){ @@ -568,13 +570,13 @@ void readModelFile(string inputFile, cvOneDOptions* opts, cvStringVec includedFi } }else if(upper_string(tokenizedString[0]) == std::string("MATERIAL")){ // printf("Found Material.\n"); - if(tokenizedString.size() > 10){ + if(tokenizedString.size() > 12){ throw cvException(string("ERROR: Too many parameters for MATERIAL token. Line " + to_string(lineCount) + "\n").c_str()); }else if(tokenizedString.size() < 8){ throw cvException(string("ERROR: Not enough parameters for MATERIAL token. Line " + to_string(lineCount) + "\n").c_str()); } try{ - // Material Name + // Material Name7 opts->materialName.push_back(tokenizedString[1]); // Material Type matType = tokenizedString[2]; @@ -583,7 +585,7 @@ void readModelFile(string inputFile, cvOneDOptions* opts, cvStringVec includedFi opts->materialDensity.push_back(atof(tokenizedString[3].c_str())); // Dynamic Viscosity opts->materialViscosity.push_back(atof(tokenizedString[4].c_str())); - // Reference Pressure + // Reference Pressureopts opts->materialPRef.push_back(atof(tokenizedString[5].c_str())); // Material Exponent opts->materialExponent.push_back(atof(tokenizedString[6].c_str())); @@ -592,10 +594,28 @@ void readModelFile(string inputFile, cvOneDOptions* opts, cvStringVec includedFi opts->materialParam1.push_back(atof(tokenizedString[7].c_str())); opts->materialParam2.push_back(atof(tokenizedString[8].c_str())); opts->materialParam3.push_back(atof(tokenizedString[9].c_str())); + if (tokenizedString.size() == 12) { // if the user has specified outflow parameters, we will read them in here + opts->materialHydraulicConductivity.push_back(atof(tokenizedString[10].c_str())); + // Material Outflow Hydraulic Conductivity + opts->materialAmbientPressure.push_back(atof(tokenizedString[11].c_str())); + // Material Outflow Ambient Pressure + } else { // if the user has not specified outflow parameters, we will fill it with 0.0 + opts->materialHydraulicConductivity.push_back(0.0); + opts->materialAmbientPressure.push_back(0.0); + } }else if(upper_string(matType) == "LINEAR"){ opts->materialParam1.push_back(atof(tokenizedString[7].c_str())); opts->materialParam2.push_back(0.0); opts->materialParam3.push_back(0.0); + if (tokenizedString.size() == 10) { // if the user has specified outflow parameters, we will read them in here + opts->materialHydraulicConductivity.push_back(atof(tokenizedString[8].c_str())); + // Material Outflow Hydraulic Conductivity + opts->materialAmbientPressure.push_back(atof(tokenizedString[9].c_str())); + // Material Outflow Ambient Pressure + } else { // if the user has not specified outflow parameters, we will fill it with 0.0 + opts->materialHydraulicConductivity.push_back(0.0); + opts->materialAmbientPressure.push_back(0.0); + } }else{ throw cvException(string("ERROR: Invalid MATERIAL Type. Line " + to_string(lineCount) + "\n").c_str()); } diff --git a/tests/__pycache__/__init__.cpython-39.pyc b/tests/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..8b04b5d Binary files /dev/null and b/tests/__pycache__/__init__.cpython-39.pyc differ diff --git a/tests/__pycache__/conftest.cpython-39-pytest-7.1.1.pyc b/tests/__pycache__/conftest.cpython-39-pytest-7.1.1.pyc new file mode 100644 index 0000000..6bc086d Binary files /dev/null and b/tests/__pycache__/conftest.cpython-39-pytest-7.1.1.pyc differ diff --git a/tests/__pycache__/test_integration.cpython-39-pytest-7.1.1.pyc b/tests/__pycache__/test_integration.cpython-39-pytest-7.1.1.pyc new file mode 100644 index 0000000..195273f Binary files /dev/null and b/tests/__pycache__/test_integration.cpython-39-pytest-7.1.1.pyc differ diff --git a/tests/cases/bifurcation_R.in b/tests/cases/bifurcation_R.in index 08179ba..18ff81c 100644 --- a/tests/cases/bifurcation_R.in +++ b/tests/cases/bifurcation_R.in @@ -69,7 +69,7 @@ ENDDATATABLE # Ref Pressure 1333.22*85 where 85 is in mmHg # Rigid for now, but can be elastic with the following parameters: # h_0 = 1.032mm, E_0 = 500 kPa, h_1 = h_2 = 0.72 mm, E_1 = E_2 = 700 kPa -MATERIAL MAT1 OLUFSEN 1.06 0.04 0 2.0 1.0e15 -20 1e9 +MATERIAL MAT1 OLUFSEN 1.06 0.04 0 2.0 1.0e15 -20 1e9 SOLVEROPTIONS 0.001087 50 1000 2 STEADY_FLOW FLOW 1.0e-6 1 1 diff --git a/tests/cases/bifurcation_R_linear.in b/tests/cases/bifurcation_R_linear.in new file mode 100644 index 0000000..0a0ecb1 --- /dev/null +++ b/tests/cases/bifurcation_R_linear.in @@ -0,0 +1,107 @@ +# Modelled from aortic bifurcation test case from +# Xiao, N., Alastruey, J., Figueroa, C.A. A systematic comparison between 1-D and 3-D hemodynamics in compliant arterial models. Int J Numer Meth Bio, 2014; 30:204-231 + +MODEL results_bifurcation_R_linear_ + +NODE 0 0.0 0.0 0.0 +NODE 1 0.0 0.0 -8.6 +NODE 2 0.0 -3.25280917510326 -7.85297602634594 +NODE 3 0.0 3.25280917510326 -7.85297602634594 + +JOINT JOINT1 1 INSEGS OUTSEGS +JOINTINLET INSEGS 1 0 +JOINTOUTLET OUTSEGS 2 1 2 + +SEGMENT seg0 0 8.6 50 0 1 2.32352192659501 2.32352192659501 0.0 MAT1 NONE 0.0 0 0 NOBOUND NONE +SEGMENT seg1 1 8.5 50 1 3 1.13097335529233 1.13097335529233 0.0 MAT1 NONE 0.0 0 0 RESISTANCE R_VALS +SEGMENT seg2 2 8.5 50 1 2 1.13097335529233 1.13097335529233 0.0 MAT1 NONE 0.0 0 0 RESISTANCE R_VALS + +DATATABLE R_VALS LIST +0.0 991.36 +ENDDATATABLE + +DATATABLE STEADY_FLOW LIST +0.0 7.985 +1.0 7.985 +ENDDATATABLE + +DATATABLE PULS_FLOW LIST +0.0 0.0 +0.019668108360095 -4.11549971450822 +0.055247073448669 -7.16517105402019 +0.089913757381125 -1.16130916560675 +0.113633067440174 9.27967911020849 +0.133703252874754 20.4428655623545 +0.150124313684865 32.8883708080991 +0.162896249870507 43.9606301469767 +0.173843623743914 54.6495650354764 +0.186615559929556 67.3593157640345 +0.204861183051901 79.6320314281343 +0.234784004972547 86.0097422945109 +0.26872086398011 78.7468811589053 +0.294264736351393 64.7319679994526 +0.314334921785973 52.023318573387 +0.32893142028385 41.4040199668672 +0.34535248109396 29.7287601931208 +0.363598104216306 17.3938305987427 +0.380019165026417 6.42196693062957 +0.396440225836527 -5.11194051566898 +0.422389556499419 -18.901261909892 +0.455347523345814 -23.8602212809087 +0.496182965572016 -18.2411583475954 +0.533485128399922 -10.4792705793446 +0.575247332435512 -4.00466780439001 +0.640931575675956 -2.79835885098868 +0.682440368279291 -5.30400645008189 +0.726077816913567 -8.52809746163143 +0.762721110017611 -9.03919130533637 +0.802405340308712 -7.30944473123762 +0.846498929521047 -5.55578067364513 +0.885944229033165 -5.87317544184486 +0.925563296384544 -7.14939949266443 +0.968258054490832 -6.10169723438909 +1.00949316274733 -4.10721983893183 +1.05237037708484 -3.31554531122748 +1.087 -1.77083891076532 +ENDDATATABLE + + +# Ref Pressure 1333.22*85 where 85 is in mmHg +# Rigid for now, but can be elastic with the following parameters: +# h_0 = 1.032mm, E_0 = 500 kPa, h_1 = h_2 = 0.72 mm, E_1 = E_2 = 700 kPa +MATERIAL MAT1 LINEAR 1.06 0.04 0 2.0 1.8e10 + +SOLVEROPTIONS 0.001087 50 1000 2 STEADY_FLOW FLOW 1.0e-6 1 1 + +OUTPUT TEXT + + +# analytical solution + +# parameters +# viscosity mu 0.04 +# seg0 length L_0 8.6 +# seg0 radius r_0 0.86 +# seg1 length L_1 8.5 (same as seg2 length) +# seg1 radius r_1 0.6 (same as seg2 radius) +# resistance BC R 991.36 +# steady Inlet Flow Q_0 7.985 +# Distal pressure Pd 0 + +# reference solution +# assumes no pressure losses at bifurcation and purely parallel resistances +# total 1D model resistance Rtot = (R_0 + 0.5*(R_2 + R) +# Pressure at junction P_0_out = P_1_in = P_2_in + +# Results to be checked +# P_0_in 3997.46433118937 +# P_0_out 3984.67700709878 +# P_1_in 3984.67700709878 (same as P_2_in) +# P_1_out 3958.0048 (same as P_2_out because symmetric) +# Q_1_in 3.9925 (same as Q_1_out) + + + + + + diff --git a/tests/cases/tube_pressure_linear.in b/tests/cases/tube_pressure_linear.in new file mode 100644 index 0000000..36ee659 --- /dev/null +++ b/tests/cases/tube_pressure_linear.in @@ -0,0 +1,37 @@ +MODEL results_tube_pressure_linear_ + +NODE 0 0.0 0.0 0.0 +NODE 1 0.0 0.0 10.0 + +SEGMENT seg0 0 10.0 50 0 1 1.0 1.0 0.0 MAT1 NONE 0.0 0 0 PRESSURE OUTLETDATA + +DATATABLE INLETDATA LIST +0.0 100.0 +10.0 100.0 +ENDDATATABLE + +DATATABLE OUTLETDATA LIST +0.0 10000.0 +ENDDATATABLE + +SOLVEROPTIONS 0.001 1000 1000 2 INLETDATA FLOW 1.0e-8 1 1 + +MATERIAL MAT1 LINEAR 1.06 0.04 0 2.0 1.8e10 + +OUTPUT TEXT + +# analytical solution + +# parameters +# viscosity mu 0.04 +# vessel length L 10 +# vessel cross-section A 1 +# vessel radius r 0.5641895835 +# pressure outlet Pout 10000 +# prescribed inflow Q 100 + +# reference solution +# vessel resistance R1 = 8*mu*L*PI/A^2 = 10.05309649 + +# results to be checked +# pressure inlet Pin = Pout + Q*R1 = 11005.30965 diff --git a/tests/cases/tube_pressure_outflow.in b/tests/cases/tube_pressure_outflow.in new file mode 100644 index 0000000..5a38e26 --- /dev/null +++ b/tests/cases/tube_pressure_outflow.in @@ -0,0 +1,46 @@ +MODEL results_tube_pressure_outflow_ + +NODE 0 0.0 0.0 0.0 +NODE 1 0.0 0.0 10.0 + +SEGMENT seg0 0 10.0 50 0 1 1.0 1.0 0.0 MAT1 NONE 0.0 0 0 PRESSURE OUTLETDATA + +DATATABLE INLETDATA LIST +0.0 100.0 +10.0 100.0 +ENDDATATABLE + +DATATABLE OUTLETDATA LIST +0.0 10000.0 +ENDDATATABLE + +SOLVEROPTIONS 0.001 1000 1000 2 INLETDATA FLOW 1.0e-8 1 1 + +MATERIAL MAT1 OLUFSEN 1.06 0.04 0 2.0 1.0e15 -20.0 1.0e9 1e-15 -1e15 + +OUTPUT TEXT + +# analytical solution + +# parameters +# density rho 1.06 +# viscosity mu 0.04 +# vessel length L 10 +# vessel cross-section A 1 +# vessel radius r 0.5641895835 +# pressure outlet Pout 10000 +# prescribed inflow Q0 100 +# prescribed outflow psi 1 + +# reference solution +# analytical result for pressure for a rigid vessel with constant outflow: +# P = -a_2/2*z^2 + a_1*z + P_out + a_2/2*L^2 - a_1*L +# where: +# a_1 = rho/A*(8/3/A*psi*Q0 + N/S*Q0) +# a_2 = rho/A*(8/3/A*psi^2 + N*psi/A) +# N = -8*pi*mu/rho +# Q = Q0 - psi*z + +# results to be checked +# pressure inlet Pin = 8269.71083336 +# flow outlet Qout = 90 diff --git a/tests/cases/tube_pressure_outflow_linear.in b/tests/cases/tube_pressure_outflow_linear.in new file mode 100644 index 0000000..4318eb7 --- /dev/null +++ b/tests/cases/tube_pressure_outflow_linear.in @@ -0,0 +1,47 @@ +MODEL results_tube_pressure_outflow_linear_ + +NODE 0 0.0 0.0 0.0 +NODE 1 0.0 0.0 10.0 + +SEGMENT seg0 0 10.0 50 0 1 1.0 1.0 0.0 MAT1 NONE 0.0 0 0 PRESSURE OUTLETDATA + +DATATABLE INLETDATA LIST +0.0 100.0 +10.0 100.0 +ENDDATATABLE + +DATATABLE OUTLETDATA LIST +0.0 10000.0 +ENDDATATABLE + +SOLVEROPTIONS 0.001 1000 1000 2 INLETDATA FLOW 1.0e-8 1 1 + +MATERIAL MAT1 LINEAR 1.06 0.04 0 2.0 1.8e10 1e-15 -1e15 + +OUTPUT TEXT + +# analytical solution + +# parameters +# density rho 1.06 +# viscosity mu 0.04 +# vessel length L 10 +# vessel cross-section A 1 +# vessel radius r 0.5641895835 +# pressure outlet Pout 10000 +# prescribed inflow Q0 100 +# prescribed outflow psi 1 + +# reference solution +# analytical result for pressure for a rigid vessel with constant outflow: +# P = -a_2/2*z^2 + a_1*z + P_out + a_2/2*L^2 - a_1*L +# where: +# a_1 = rho/A*(8/3/A*psi*Q0 + N/S*Q0) +# a_2 = rho/A*(8/3/A*psi^2 + N*psi/A) +# N = -8*pi*mu/rho +# Q = Q0 - psi*z + +# results to be checked +# pressure inlet Pin = 8269.71083336 +# flow outlet Qout = 90 + diff --git a/tests/cases/tube_pressure_outflow_linear.in~ b/tests/cases/tube_pressure_outflow_linear.in~ new file mode 100644 index 0000000..f41d7d9 --- /dev/null +++ b/tests/cases/tube_pressure_outflow_linear.in~ @@ -0,0 +1,37 @@ +MODEL results_tube_pressure_outflow_ + +NODE 0 0.0 0.0 0.0 +NODE 1 0.0 0.0 10.0 + +SEGMENT seg0 0 10.0 50 0 1 1.0 1.0 0.0 MAT1 NONE 0.0 0 0 PRESSURE OUTLETDATA + +DATATABLE INLETDATA LIST +0.0 100.0 +10.0 100.0 +ENDDATATABLE + +DATATABLE OUTLETDATA LIST +0.0 10000.0 +ENDDATATABLE + +SOLVEROPTIONS 0.001 1000 1000 2 INLETDATA FLOW 1.0e-8 1 1 + +MATERIAL MAT1 OLUFSEN 1.06 0.04 0 2.0 1.0e15 -20.0 1.0e9 1e-15 -1e15 + +OUTPUT TEXT + +# analytical solution + +# parameters +# viscosity mu 0.04 +# vessel length L 10 +# vessel cross-section A 1 +# vessel radius r 0.5641895835 +# pressure outlet Pout 10000 +# prescribed inflow Q 100 + +# reference solution +# vessel resistance R1 = 8*mu*L*PI/A^2 = 10.05309649 + +# results to be checked +# pressure inlet Pin = Pout + Q*R1 = 11005.30965 diff --git a/tests/cases/tube_r_stab_linear.in b/tests/cases/tube_r_stab_linear.in new file mode 100644 index 0000000..57bc47c --- /dev/null +++ b/tests/cases/tube_r_stab_linear.in @@ -0,0 +1,38 @@ +MODEL results_tube_r_stab_linear_ + +NODE 0 0.0 0.0 0.0 +NODE 1 0.0 0.0 10.0 + +SEGMENT seg0 0 10.0 50 0 1 1.0 1.0 0.0 MAT1 NONE 0.0 0 0 RESISTANCE OUTLETDATA + +DATATABLE INLETDATA LIST +0.0 100.0 +10.0 100.0 +ENDDATATABLE + +DATATABLE OUTLETDATA LIST +0.0 100.0 +ENDDATATABLE + +SOLVEROPTIONS 0.001 500 500 2 INLETDATA FLOW 1.0e-8 1 0 + +MATERIAL MAT1 LINEAR 1.06 0.04 0 2.0 1.0e11 + +OUTPUT TEXT + +# analytical solution + +# parameters +# viscosity mu 0.04 +# vessel length L 10 +# vessel cross-section A 1 +# vessel radius r 0.5641895835 +# resistance BC R2 100 +# prescribed inflow Q 100 + +# reference solution +# vessel resistance R1 = 8*mu*L*PI/A^2 = 10.05309649 + +# results to be checked +# pressure inlet Pin = Q*(R1+R2) = 11005.30965 +# pressure outlet Pout = Q*R2 = 10000 diff --git a/tests/test_integration.py b/tests/test_integration.py index aa957a4..b0f14a4 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -103,6 +103,30 @@ def test_tube_pressure(tmpdir): assert np.isclose(get_result(results, 'area', 0, -1, -1, 'point'), 1.0, rtol=1.0e-5) +def test_tube_pressure_linear(tmpdir): + results = run_test_case_by_name('tube_pressure_linear', tmpdir) + assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 11005.30965, rtol=1.0e-6) + assert np.isclose(get_result(results, 'pressure', 0, -1, -1, 'point'), 10000.0, rtol=1.0e-8) + assert np.isclose(get_result(results, 'flow', 0, -1, -1, 'point'), 100.0, rtol=1.0e-16) + assert np.isclose(get_result(results, 'area', 0, -1, -1, 'point'), 1.0, rtol=1.0e-5) + + +def test_tube_pressure_outflow(tmpdir): + results = run_test_case_by_name('tube_pressure_outflow', tmpdir) + assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 8269.71083336, rtol=1.0e-5) + assert np.isclose(get_result(results, 'pressure', 0, -1, -1, 'point'), 10000.0, rtol=1.0e-8) + assert np.isclose(get_result(results, 'flow', 0, -1, -1, 'point'), 90.0, rtol=1.0e-8) + assert np.isclose(get_result(results, 'area', 0, -1, -1, 'point'), 1.0, rtol=1.0e-5) + + +def test_tube_pressure_outflow_linear(tmpdir): + results = run_test_case_by_name('tube_pressure_outflow_linear', tmpdir) + assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 8269.71083336, rtol=1.0e-5) + assert np.isclose(get_result(results, 'pressure', 0, -1, -1, 'point'), 10000.0, rtol=1.0e-8) + assert np.isclose(get_result(results, 'flow', 0, -1, -1, 'point'), 90.0, rtol=1.0e-8) + assert np.isclose(get_result(results, 'area', 0, -1, -1, 'point'), 1.0, rtol=1.0e-5) + + def test_tube_pressure_wave(tmpdir): results = run_test_case_by_name('tube_pressure_wave', tmpdir) assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 10000.0 , rtol=1.0e-8) @@ -151,6 +175,14 @@ def test_tube_r_stab(tmpdir): assert np.isclose(get_result(results, 'area', 0, -1, -1, 'point'), 1.0, rtol=1.0e-5) +def test_tube_r_stab_linear(tmpdir): + results = run_test_case_by_name('tube_r_stab_linear', tmpdir) + assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 11005.30965, rtol=1.0e-6) + assert np.isclose(get_result(results, 'pressure', 0, -1, -1, 'point'), 10000.0, rtol=1.0e-8) + assert np.isclose(get_result(results, 'flow', 0, -1, -1, 'point'), 100.0, rtol=1.0e-16) + assert np.isclose(get_result(results, 'area', 0, -1, -1, 'point'), 1.0, rtol=1.0e-5) + + def test_tube_stenosis_r(tmpdir): results = run_test_case_by_name('tube_stenosis_r', tmpdir) assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 10150.68211, rtol=1.0e-6) @@ -183,6 +215,18 @@ def test_bifurcation_R(tmpdir): assert np.isclose(get_result(results, 'flow', 2, -1, -1, 'point'), 3.9925, rtol=1e-5) +def test_bifurcation_R_linear(tmpdir): + results = run_test_case_by_name('bifurcation_R_linear', tmpdir) + assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 3997.46433118937, rtol=1e-5) + assert np.isclose(get_result(results, 'pressure', 0, -1, -1, 'point'), 3984.67700709878, rtol=1e-5) + assert np.isclose(get_result(results, 'pressure', 1, 0, -1, 'point'), 3984.67700709878, rtol=1e-5) + assert np.isclose(get_result(results, 'pressure', 2, 0, -1, 'point'), 3984.67700709878, rtol=1e-5) + assert np.isclose(get_result(results, 'pressure', 1, -1, -1, 'point'), 3958.0048, rtol=1e-5) + assert np.isclose(get_result(results, 'pressure', 2, -1, -1, 'point'), 3958.0048, rtol=1e-5) + assert np.isclose(get_result(results, 'flow', 1, -1, -1, 'point'), 3.9925, rtol=1e-5) + assert np.isclose(get_result(results, 'flow', 2, -1, -1, 'point'), 3.9925, rtol=1e-5) + + def test_bifurcation_R_stab(tmpdir): results = run_test_case_by_name('bifurcation_R_stab', tmpdir) assert np.isclose(get_result(results, 'pressure', 0, 0, -1, 'point'), 3997.46433118937, rtol=1e-6)