示例#1
0
 void VPStandardStateTP::setState_TP(doublereal t, doublereal pres) {
   /*
    *  A pretty tricky algorithm is needed here, due to problems involving
    *  standard states of real fluids. For those cases you need 
    *  to combine the T and P specification for the standard state, or else
    *  you may venture into the forbidden zone, especially when nearing the
    *  triple point.
    *     Therefore, we need to do the standard state thermo calc with the
    *  (t, pres) combo.
    */
   State::setTemperature(t);
   m_Pcurrent = pres;
   updateStandardStateThermo();
   /*
    * Now, we still need to do the calculations for general ThermoPhase objects.
    * So, we switch back to a virtual function call, setTemperature, and 
    * setPressure to recalculate stuff for child ThermoPhase objects of 
    * the VPStandardStateTP object. At this point,
    * we haven't touched m_tlast or m_plast, so some calculations may still
    * need to be done at the ThermoPhase object level.
    */
   //setTemperature(t);
   //setPressure(pres);
   calcDensity();
 }
void TargetExtractor::fill(int ksize, int threshold)
{
    int r = (ksize - 1) / 2;
    if (r <= 0) {
        return;
    }

    Mat density;
    calcDensity(mMask, density, ksize);

    double half = ksize / 2.0, dist = ksize / 5.0;
    int max = ksize * ksize * 9 / 10;

    for (int i = r; i < mMask.rows - r; i++) {
        for (int j = r; j < mMask.cols - r; j++) {
            int count = density.at<int>(i, j);
            if (count > max) {
                mMask.at<uchar>(i, j) = 255;
            } else if (count >= threshold) {
                // TODO: further optimize the mass-center calculation
                Point center;
                Rect rect(j - r, i - r, ksize, ksize);
                getMassCenter(mMask(rect), center);
                if (abs(center.x - half) < dist && abs(center.y - half) < dist) {
                    mMask.at<uchar>(i, j) = 255;
                }
            }
        }
    }
}
示例#3
0
void  LatticeSolidPhase::setPressure(doublereal p)
{
    m_press = p;
    for (size_t n = 0; n < m_nlattice; n++) {
        m_lattice[n]->setPressure(m_press);
    }
    calcDensity();
}
示例#4
0
float wvutilsCalculateAirDensity (float tempF, float bp, float dp)
{
    float       tempC = wvutilsConvertFToC (tempF);
    float       bpMB = wvutilsConvertINHGToHPA (bp);
    float       dewpoint = wvutilsConvertFToC (dp);
    float       emb = getVaporPressure (dewpoint);
    float       density = calcDensity (bpMB, emb, tempC);

    return density;
}
示例#5
0
unsigned char *tx(float *points,
                  float *weights,
                  int cPoints,
                  int w, int h,
                  int dotsize,
                  int *scheme,
                  unsigned char *pix_color,
                  int opacity,
                  int boundsOverride,
                  float minX, float minY, float maxX, float maxY)
{
    unsigned char *pixels_bw = NULL;

    //basic sanity checks to keep from segfaulting
    if (NULL == points || NULL == weights || NULL == scheme || NULL == pix_color ||
        w <= 0 || h <= 0 || cPoints <= 1 || opacity < 0 || dotsize <= 0)
    {
        fprintf(stderr, "Invalid parameter; aborting.\n");
        return NULL;
    }


    DOTSIZE = dotsize;
    WIDTH = w;
    HEIGHT = h;

    // get min/max x/y values from point list
    if (boundsOverride == 1)
    {
        MAX_X = maxX; MIN_X = minX;
        MAX_Y = maxY; MIN_Y = minY;
    }
    else
    {
        getBounds(points, cPoints);
    }

    #ifdef DEBUG
    printf("min: (%.2f, %.2f) max: (%.2f, %.2f)\n", MIN_X, MIN_Y, MAX_X, MAX_Y);
    #endif

    //iterate through points, place a dot at each center point
    //and set pix value from 0 - 255 using multiply method for radius [dotsize].
    pixels_bw = calcDensity(points, weights, cPoints);

    //using provided color scheme and opacity, update pixel value to RGBA values
    pix_color = colorize(pixels_bw, scheme, pix_color, opacity);

    free(pixels_bw);
    pixels_bw = NULL;

    //return list of RGBA values
    return pix_color;
}
示例#6
0
void LatticeSolidPhase::setMoleFractions(const doublereal* const x)
{
    size_t nsp, strt = 0;
    for (size_t n = 0; n < m_nlattice; n++) {
        nsp =  m_lattice[n]->nSpecies();
        m_lattice[n]->setMoleFractions(x + strt);
        strt += nsp;
    }
    for (size_t k = 0; k < strt; k++) {
        m_x[k] = x[k] / m_nlattice;
    }
    Phase::setMoleFractions(DATA_PTR(m_x));
    calcDensity();
}
示例#7
0
 void GibbsExcessVPSSTP::setState_TP(doublereal t, doublereal p) {
   State::setTemperature(t);
   /*
    * Store the current pressure
    */
   m_Pcurrent = p;
   /*
    * update the standard state thermo
    * -> This involves calling the water function and setting the pressure
    */
   updateStandardStateThermo();
 
   /*
    * Calculate the partial molar volumes, and then the density of the fluid
    */
   calcDensity();
 }
示例#8
0
RegionEvaluator::PrioSplit PolygonDensityEvaluator::calcPriority(const std::vector<Geometry::Box> & boxes) {
	std::vector<float> values;
	float prio=0;
	float sum=0;
	bool isConst = true;

	for(const auto & box : boxes){
		float f = calcDensity(box);
		values.push_back(f);
		if(f!=values.front())
			isConst = false;
		sum += f;
	}
	if(isConst)
		return PrioSplit(0.0,0.5);

	float avg = sum/values.size();

	for (auto & value : values)
		value -= avg;

	float left = 0;
	float maxDiff = 0;
	size_t maxDiffIndex = values.size() / 2;
	for (size_t i = 1; i < values.size(); i++) {
		left += values[i];
		if (std::abs(left) > maxDiff) {
			maxDiff = std::abs(left);
			maxDiffIndex = i;
		}
	}

	switch(getAttribute(Util::StringIdentifier("Test Mode"))->toUnsignedInt()) {
	case 0: // absolute difference
		prio = maxDiff;
		break;
	case 1: // relative difference
		prio = maxDiff / avg;
		break;
	default:
		FAIL();
	}

	return PrioSplit(prio,static_cast<double>(maxDiffIndex)/static_cast<double>(values.size()));
}
void TargetExtractor::denoise(int ksize, int threshold)
{
    int r = (ksize - 1) / 2;
    if (r <= 0) {
        return;
    }

    Mat density;
    calcDensity(mMask, density, ksize);

    for (int i = r; i < mMask.rows - r; i++) {
        for (int j = r; j < mMask.cols - r; j++) {
            int count = density.at<int>(i, j);
            if (count < threshold) {
                mMask.at<uchar>(i, j) = 0;
            }
        }
    }
}
void LatticePhase::setMoleFractions(const doublereal* const x)
{
    Phase::setMoleFractions(x);
    calcDensity();
}
void LatticePhase::setPressure(doublereal p)
{
    m_Pcurrent = p;
    calcDensity();
}
void LatticePhase::setConcentrations(const doublereal* const c)
{
    Phase::setConcentrations(c);
    calcDensity();
}
void LatticePhase::setMassFractions_NoNorm(const doublereal* const y)
{
    Phase::setMassFractions_NoNorm(y);
    calcDensity();
}
示例#14
0
void IdealSolidSolnPhase::setMoleFractions_NoNorm(const doublereal* const x)
{
    Phase::setMoleFractions(x);
    calcDensity();
}
示例#15
0
void IdealSolidSolnPhase::setMassFractions_NoNorm(const doublereal* const y)
{
    Phase::setMassFractions_NoNorm(y);
    calcDensity();
}
示例#16
0
 void GibbsExcessVPSSTP::setConcentrations(const doublereal* const c) {
   State::setConcentrations(c);
   getMoleFractions(DATA_PTR(moleFractions_));
   calcDensity();
 }
示例#17
0
 void GibbsExcessVPSSTP::setMoleFractions_NoNorm(const doublereal* const x) {
   State::setMoleFractions_NoNorm(x);
   getMoleFractions(DATA_PTR(moleFractions_));
   calcDensity();
 }
示例#18
0
void IdealSolidSolnPhase::setPressure(doublereal p)
{
    m_Pcurrent = p;
    calcDensity();
}
示例#19
0
void IdealSolidSolnPhase::setConcentrations(const doublereal* const c)
{
    Phase::setConcentrations(c);
    calcDensity();
}
示例#20
0
void
ZouHeDynamics::defineVelocity(DataType& data, VelocityType velocity) const noexcept
{
    const auto density = calcDensity(data, velocity);
    init(data, velocity, density);
}
示例#21
0
 void GibbsExcessVPSSTP::setMassFractions(const doublereal* const y) {
   State::setMassFractions(y);
   getMoleFractions(DATA_PTR(moleFractions_));
   calcDensity();
 }
示例#22
0
 void IdealSolnGasVPSS::setPressure(doublereal p) {
   m_Pcurrent = p;
   updateStandardStateThermo();
   calcDensity();
 }