//' @title Model Score //' @description Calculates the modeling score of a GMWM //' @param A A \code{mat} that contains the first derivatives of the processes //' @param At_j A \code{mat} that contains the second derivative of each process //' @param omega A \code{mat} that contains the omega used when calculating the GMWM //' @param v_hat A \code{mat} that contains the covariance matrix //' @param diff A \code{vec} that is the difference of the WV empirical and WV theoretical //' @return A \code{vec} //' @keywords internal //' @backref src/model_selection.cpp //' @backref src/model_selection.h //' @details //' The equation is slightly different than that stated in the paper due to the bootstrap already incorporating in //' N. // [[Rcpp::export]] arma::vec model_score(arma::mat A, arma::mat D, arma::mat omega, arma::mat v_hat, double obj_value){ arma::mat At = arma::trans(A); arma::mat B = B_matrix(A, At*omega); arma::mat d_b = D-B; arma::mat db_t = arma::trans(d_b); arma::mat dTheta = -1*arma::pinv(db_t * d_b)*db_t*At*omega; arma::vec score_info(2); double optimism = 2.0*arma::as_scalar(arma::trace(A * dTheta * omega * v_hat)); score_info(0) = obj_value + optimism; score_info(1) = optimism; // Return the score return score_info; }
//with matrixtype, constant coefficient void NoNewtonianMonolithicPFEM22D::AddViscousTerm(MatrixType& OutputMatrix, const boost::numeric::ublas::bounded_matrix<double, 3, 2 >& rShapeDeriv, double Viscosity, const double Area) { const double theta = 0.35; const double Cohesion = 0.0; double base_viscosity = Viscosity; boost::numeric::ublas::bounded_matrix<double, 6, 3 > B_matrix = ZeroMatrix(6,3); for (unsigned int i=0; i!=3; i++) //i node { B_matrix(i*2,0)=rShapeDeriv(i,0); B_matrix(i*2+1,1)=rShapeDeriv(i,1); B_matrix(i*2,2)=rShapeDeriv(i,1); B_matrix(i*2+1,2)=rShapeDeriv(i,0); } boost::numeric::ublas::bounded_matrix<double, 3, 3 > C_matrix = ZeroMatrix(3,3); C_matrix(0,0)=2.0; C_matrix(1,1)=2.0; C_matrix(2,2)=1.0; double pressure = 0.0; double negative_nodes=0.0; double has_fixed_vel=false; //if some nodes are fixed, then we are on a boundary and then we can set different material properties (for example to simulate a lower basal friction angle) for (unsigned int i=0; i!=3; i++) //i node { if (this->GetGeometry()[i].FastGetSolutionStepValue(DISTANCE)<0.0) { pressure += this->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE); negative_nodes +=1.0; } if (this->GetGeometry()[i].IsFixed(VELOCITY_X)==true) has_fixed_vel = true; } pressure /=negative_nodes; if (pressure<0.0) pressure=0.0; double YieldStress = Cohesion + tan(theta) * pressure; //if (theta>basal_theta && has_fixed_vel) // YieldStress = tan(basal_theta) * pressure; if (negative_nodes>0.5) { Viscosity = this->EffectiveViscosity(base_viscosity,YieldStress,rShapeDeriv); } C_matrix *= Viscosity*Area; boost::numeric::ublas::bounded_matrix<double, 3, 6 > temp_matrix = prod(C_matrix,trans(B_matrix)); boost::numeric::ublas::bounded_matrix<double, 6, 6 > viscosity_matrix = prod(B_matrix, temp_matrix ); for (unsigned int i=0; i!=3; i++) //i node { for (unsigned int j=0; j!=3; j++) //j neighbour { //OutputMatrix(i*4+0,j*4+0)+=viscosity_matrix(i*2+0,j*2+0); //0,0 //OutputMatrix(i*4+0,j*4+1)+=viscosity_matrix(i*2+0,j*2+1); //0,1 //OutputMatrix(i*4+1,j*4+0)+=viscosity_matrix(i*2+1,j*2+0); //1,0 //OutputMatrix(i*4+1,j*4+1)+=viscosity_matrix(i*2+1,j*2+1); //1,1 OutputMatrix(i*3+0,j*3+0)+=viscosity_matrix(i*2+0,j*2+0); //0,0 OutputMatrix(i*3+0,j*3+1)+=viscosity_matrix(i*2+0,j*2+1); //0,1 OutputMatrix(i*3+1,j*3+0)+=viscosity_matrix(i*2+1,j*2+0); //1,0 OutputMatrix(i*3+1,j*3+1)+=viscosity_matrix(i*2+1,j*2+1); //1,1 } } //OutputMatrix += viscosity_matrix; }