Beispiel #1
0
 double BlackoilCo2PVT::R(double press, const CompVec& surfvol, PhaseIndex phase) const
 {
     SubState ss;
     computeState(ss, surfvol[Oil], surfvol[Gas], press);
     switch(phase) {
     case Aqua: return 0.0;
     case Liquid: return (ss.massfrac[wPhase][nComp]*surfaceDensities_[Oil])/(ss.massfrac[wPhase][wComp]*surfaceDensities_[Gas]+1.0e-10);
     case Vapour: return (ss.massfrac[nPhase][wComp]*surfaceDensities_[Gas])/(ss.massfrac[nPhase][nComp]*surfaceDensities_[Oil]+1.0e-10);
     };
     return 0.0;
 }
Beispiel #2
0
 double BlackoilCo2PVT::getViscosity(double press, const CompVec& surfvol, PhaseIndex phase) const
 {
     SubState ss;
     computeState(ss, surfvol[Oil], surfvol[Gas], press);
     switch(phase) {
     case Aqua: return 1.0e-10;
     case Liquid: return ss.phaseViscosity[wPhase];
     case Vapour: return ss.phaseViscosity[nPhase];
     };
     return 1.0e-10;
 }
Beispiel #3
0
 double BlackoilCo2PVT::getSaturation(double press, const CompVec& surfvol, PhaseIndex phase) const
 {
     SubState ss;
     computeState(ss, surfvol[Oil], surfvol[Gas], press);
     switch(phase) {
     case Aqua: return 0.0;
     case Liquid: return ss.saturation;
     case Vapour: return 1.0 - ss.saturation;
     };
     return 0.0;
 }
void _StateCompute(void)
{
	if (computeState == NULL | currentState == STATE_UNKNOW)
	{
		printf("[ERROR]\tcomputeState is NULL, no instance selected\n");
		//getc();
		exit(1);
	}
	else
		computeState();
}
Beispiel #5
0
 void BlackoilCo2PVT::dRdp(const std::vector<PhaseVec>& pressures,
                        const std::vector<CompVec>& surfvol,
                        std::vector<PhaseVec>& output_R,
                        std::vector<PhaseVec>& output_dRdp) const
 {
     int num = pressures.size();
     output_R.resize(num);
     output_dRdp.resize(num);
     SubState ss;
     const double dp = 100.;
     for (int i = 0; i < num; ++i) {
         computeState(ss, surfvol[i][Oil], surfvol[i][Gas], pressures[i][Liquid]);
         output_R[i][Aqua] = 0.0;
         output_R[i][Liquid] = (ss.massfrac[wPhase][nComp]*surfaceDensities_[Oil])/(ss.massfrac[wPhase][wComp]*surfaceDensities_[Gas]+1.0e-10);
         output_R[i][Vapour] = (ss.massfrac[nPhase][wComp]*surfaceDensities_[Gas])/(ss.massfrac[nPhase][nComp]*surfaceDensities_[Oil]+1.0e-10);
         computeState(ss, surfvol[i][Oil], surfvol[i][Gas], pressures[i][Liquid]+dp);
         output_dRdp[i][Aqua] = 0.0;
         output_dRdp[i][Liquid] = ((ss.massfrac[wPhase][nComp]*surfaceDensities_[Oil])/(ss.massfrac[wPhase][wComp]*surfaceDensities_[Gas]+1.0e-10) - output_R[i][Liquid])/dp;
         output_dRdp[i][Vapour] = ((ss.massfrac[nPhase][wComp]*surfaceDensities_[Gas])/(ss.massfrac[nPhase][nComp]*surfaceDensities_[Oil]+1.0e-10) - output_R[i][Vapour])/dp;
     }
 }
    void Button::onMouseClick(MouseButton button, MouseState state, const Vector2& mousePosition)
    {
        if (button == BUTTON_LEFT)
        {
            mIsPressed = !mIsPressed;

			computeState();

            if (state == MOUSE_DOWN)
                mCallBack(button, state, mousePosition);
        }
    }
Beispiel #7
0
PyView *PyView::getSlice(int s, int e) {
  int sz = GetSize();
  if (s < 0)
    s += sz;
  if (e < 0)
    e += sz;
  if (e > sz)
    e = sz;
  if (s >= 0 && s < sz)
    if (e > s && e <= sz)
      return new PyView(Slice(s,e), 0, computeState(RWVIEWER));
  return new PyView(Clone());
}
Beispiel #8
0
 void BlackoilCo2PVT::R(const std::vector<PhaseVec>& pressures,
                     const std::vector<CompVec>& surfvol,
                     std::vector<PhaseVec>& output) const
 {
     int num = pressures.size();
     output.resize(num);
     SubState ss;
     for (int i = 0; i < num; ++i) {
         computeState(ss, surfvol[i][Oil], surfvol[i][Gas], pressures[i][Liquid]);
         output[i][Aqua] = 0.0;
         output[i][Liquid] = (ss.massfrac[wPhase][nComp]*surfaceDensities_[Oil])/(ss.massfrac[wPhase][wComp]*surfaceDensities_[Gas]+1.0e-10);
         output[i][Vapour] = (ss.massfrac[nPhase][wComp]*surfaceDensities_[Gas])/(ss.massfrac[nPhase][nComp]*surfaceDensities_[Oil]+1.0e-10);
     }
 }
Beispiel #9
0
 void BlackoilCo2PVT::getViscosity(const std::vector<PhaseVec>& pressures,
                                const std::vector<CompVec>& surfvol,
                                std::vector<PhaseVec>& output) const
 {
     int num = pressures.size();
     output.resize(num);
     SubState ss;
     for (int i = 0; i < num; ++i) {
         computeState(ss, surfvol[i][Oil], surfvol[i][Gas], pressures[i][Liquid]);
         output[i][Aqua] = 1.0e-10;
         output[i][Liquid] = ss.phaseViscosity[wPhase];
         output[i][Vapour] = ss.phaseViscosity[nPhase];
     }
 }
void InfiniteRadialAnimation::draw(
		Painter &p,
		QPoint position,
		QSize size,
		int outerWidth) {
	const auto state = computeState();

	auto o = p.opacity();
	p.setOpacity(o * state.shown);

	const auto rect = rtlrect(
		position.x(),
		position.y(),
		size.width(),
		size.height(),
		outerWidth);
	const auto was = p.pen();
	const auto brush = p.brush();
	if (anim::Disabled()) {
		anim::DrawStaticLoading(p, rect, _st.thickness, _st.color);
	} else {
		auto pen = _st.color->p;
		pen.setWidth(_st.thickness);
		pen.setCapStyle(Qt::RoundCap);
		p.setPen(pen);

		{
			PainterHighQualityEnabler hq(p);
			p.drawArc(
				rect,
				state.arcFrom,
				state.arcLength);
		}
	}
	p.setPen(was);
	p.setBrush(brush);
	p.setOpacity(o);
}
void RadialAnimation::draw(
		Painter &p,
		const QRect &inner,
		int32 thickness,
		style::color color) {
	const auto state = computeState();

	auto o = p.opacity();
	p.setOpacity(o * state.shown);

	auto pen = color->p;
	auto was = p.pen();
	pen.setWidth(thickness);
	pen.setCapStyle(Qt::RoundCap);
	p.setPen(pen);

	{
		PainterHighQualityEnabler hq(p);
		p.drawArc(inner, state.arcFrom, state.arcLength);
	}

	p.setPen(was);
	p.setOpacity(o);
}
void AnalogFiveButtons::update()
{
  static byte previousStateIndex = 0;
  static int previousReading = 0;
  static unsigned int previousSampleTime = 0;
#ifdef A5B_TIMING_DBG
  static uint16_t measureCounter = 0;
#endif
  static bool acquired = false;
  

  // Get current time
  unsigned long currentSampleTime = millis();

  // Start to process only if enough time has elapsed
  if ( currentSampleTime > (previousSampleTime+m_msSampling) ) {

    // Read the current analog input pin
    int currentReading = analogRead(m_analogPin);
    
      // Check if the reading is not varying much from the previous
      // We basically wait for the derivative of the voltage to fall
      // under 2 bits of accuracy (assuming that the difference 
      // between any state is higher than 2 bits)
      if ( abs(previousReading-currentReading) < 4 ) {

        if ( !acquired ) {
          m_counter--;	// new stable reading
          Serial.println(m_counter, DEC);
          if ( m_counter == 0 ) {
            // compute the new state
            m_currentStateIndex = computeState(currentReading);
            // remember that we have a new measurement
            acquired = true;
            // Detect the button going down
            // if ( m_currentStateIndex != previousStateIndex ) {
            //   m_buttonPressed = 
            //     ~(m_states[previousStateIndex]) & m_states[m_currentStateIndex];
            //   previousStateIndex = m_currentStateIndex;
            // }
#ifdef A5B_TIMING_DBG
              Serial.print("stable voltage achieved after: ");
              Serial.println(measureCounter, DEC);
#endif
              m_buttonPressed |= m_states[m_currentStateIndex];
          }
        }
#ifdef A5B_TIMING_DBG
        measureCounter = 0;
#endif
      } // if stable reading
      else {
        m_counter = m_debounceSamples;
        acquired = false;
#ifdef A5B_TIMING_DBG
        measureCounter++;
#endif
      }
    previousReading = currentReading;
    previousSampleTime = currentSampleTime;
    
  }
}
 ParameterState computeState( ParameterType leak, DSPContext const & )
 {
     return computeState(leak);
 }
void MarkovSolverBase::process( const Eref& e, ProcPtr p )
{
	computeState();	

	stateOut()->send( e, p->threadIndexInGroup, state_ );
}
Beispiel #15
0
void MarkovSolverBase::process( const Eref& e, ProcPtr p )
{
	computeState();	

	stateOut()->send( e, state_ );
}