コード例 #1
0
void OpenSMOKE_KPP_SingleReactor::SolveCSTR_Corrector_Linearized(const double deltat, BzzMatrix &tmpMatrix)
{
	// Reactions	
	kinetics->UpdateProperties(omega_, temperature_, pressure_, R_);
	Product(volume_, R_, &RV_);
	GetJacobian(omega_, tmpMatrix);				// A = d(RV)/domega * Volume/mtot;

	// The formulation is the same, both for deferred=on and deferred=off
	// The difference is the Jacobian calculation (see GetJacobian function)
	if (data_->PredictorCorrector_DeferredConvection() == false || 
		data_->PredictorCorrector_DeferredConvection() == true)
	{
		// Rigth hand side
		Product(-M_, omega_, &rhs_);		//	outflow
		Sum(&rhs_, RV_);				//	reaction
		Sum(&rhs_, mInTot_);			//  inflow
		rhs_ *= deltat/mass_;		
	
		// Matrix
		tmpMatrix *= -deltat;			
		for(int i=1;i<=numberOfSpecies;i++)
			tmpMatrix[i][i] += 1.;
	
		// Linear System solution
		BzzFactorizedGauss AGauss(tmpMatrix);
		Solve(AGauss, &rhs_);

		// Updating
		omega_ += rhs_;
	}
}
コード例 #2
0
void OpenSMOKE_KPP_SingleReactor::PrepareJacobianNewtonMethod(BzzFactorizedGauss& JacobianFactorized, BzzVector& omega, BzzMatrix &tmpMatrix)
{
		GetJacobian(omega, tmpMatrix);				// A = d(RV)/domega * Volume/mtot;
		Product(mass_, &tmpMatrix);
		for(int i=1;i<=numberOfSpecies;i++)
			tmpMatrix[i][i] -= M_;
		JacobianFactorized = tmpMatrix;
}
コード例 #3
0
void TransformNDOF::GetHessian(const scalarArray &q, se3DbAry &H)
{
	se3Array J(m_iDOF), dJ(m_iDOF);
	
	GetJacobian(q, J);

	scalarArray dq(m_iDOF);
	for ( int i = 0; i < m_iDOF; i++ ) dq[i] = q[i];

	for ( int i = 0; i < m_iDOF; i++ )
	{
		dq[i] += m_rEPS;
		GetJacobian(dq, dJ);
		for ( int j = i + 1; j < m_iDOF; j++ ) H[i][j] = (SCALAR_1 / m_rEPS) * (dJ[j] - J[j]);
		dq[i] -= m_rEPS;
	}
}
コード例 #4
0
void DynamicChain2D::Update_J()
{
	JP.resize(q.n,q.n);
	JO.resize(q.n,q.n);
	for(int i=0;i<q.n;i++) {
		for(int j=0;j<q.n;j++) {
			if(!GetJacobian(links[i].com,i,j,JO(i,j),JP(i,j))) { }
		}
	}
}
コード例 #5
0
int DiscreteJacobianField::Inverse(const Sample & sample, Matrix & jacobian) const
{
    return GetJacobian(_inverse_jacobians, sample, jacobian);
}
コード例 #6
0
int DiscreteJacobianField::Forward(const Sample & sample, Matrix & jacobian) const
{
    return GetJacobian(_forward_jacobians, sample, jacobian);
}
コード例 #7
0
void OpenSMOKE_KPP_SingleReactor::AssemblingDiagonalBlockMatrix(const double deltat, BzzMatrix &tmpMatrix, BzzMatrix &diagonalBlockMatrix)
{	
	if (data_->networkStatus() == KPP_NETWORK_STATUS_GLOBALODE)
	{
		// Jacobian	
		GetJacobian(omega_, tmpMatrix);				// A =  d(RV)/domega /mtot;
		Product(-deltat, &tmpMatrix);				// A = -d(RV)/domega /mtot*deltat;

		// DiagonalBlockMatrix
		diagonalBlockMatrix = 0.;
		diagonalBlockMatrix.SetDiagonal(0, 1.+M_*deltat/mass_);
		Sum(&diagonalBlockMatrix, tmpMatrix);

		// Global values for row block corresponding to the current reactor)
		{
			BzzVector mConvectionDiffusion_x_deltat_over_mass = mConvectionDiffusion_;
			Product(deltat/mass_, &mConvectionDiffusion_x_deltat_over_mass);

			int count=1;
			for (int i=1;i<=numberOfSpecies;i++)
			{
				for (int k=1;k<=mConvectionDiffusion_.Size();k++)
					if (iConvectionDiffusion_[k] < int(index_))
						globalIndicesSparsityValues_[count++] = -mConvectionDiffusion_x_deltat_over_mass[k];

				for (int k=1;k<=numberOfSpecies;k++)
					globalIndicesSparsityValues_[count++] = diagonalBlockMatrix[i][k];

				for (int k=1;k<=mConvectionDiffusion_.Size();k++)
					if (iConvectionDiffusion_[k] > int(index_))
						globalIndicesSparsityValues_[count++] = -mConvectionDiffusion_x_deltat_over_mass[k];
			}
		}

	}
	else if (data_->networkStatus() == KPP_NETWORK_STATUS_GLOBALNLS)
	{
		// Jacobian	
		GetJacobian(omega_, tmpMatrix);				// A =  d(RV)/domega /mtot;
		Product(-mass_, &tmpMatrix);

		// DiagonalBlockMatrix
		diagonalBlockMatrix = 0.;
		diagonalBlockMatrix.SetDiagonal(0, M_);
		Sum(&diagonalBlockMatrix, tmpMatrix);

		// Global values for row block corresponding to the current reactor)
		{

			int count=1;
			for (int i=1;i<=numberOfSpecies;i++)
			{
				for (int k=1;k<=mConvectionDiffusion_.Size();k++)
					if (iConvectionDiffusion_[k] < int(index_))
						globalIndicesSparsityValues_[count++] = -mConvectionDiffusion_[k];

				for (int k=1;k<=numberOfSpecies;k++)
					globalIndicesSparsityValues_[count++] = diagonalBlockMatrix[i][k];

				for (int k=1;k<=mConvectionDiffusion_.Size();k++)
					if (iConvectionDiffusion_[k] > int(index_))
						globalIndicesSparsityValues_[count++] = -mConvectionDiffusion_[k];
			}
		}
	}
	else
		ErrorMessage("AssemblingDiagonalBlockMatrix is available only for KINPP_NETWORK_STATUS_GLOBALODE or KINPP_NETWORK_STATUS_GLOBALNLS");		
}