TEST_FIXTURE(CharacteristicMatrixTestFixture, AirTransmissionAndReflection)
{
  double wavelength = 400e-9;
  HomogeneousCharacteristicMatrix air(air_index, 1e-3, wavelength);
  CHECK_EQUAL(1.0, air.TransmissionInEnvironment());
  CHECK_EQUAL(0.0, air.ReflectivityInEnvironment());
}
Esempio n. 2
0
void Predictor::setupFile ( )
{
	char _outFile[100];
	char _dateStr[9];
	char _timeStr[9];

	_strdate( _dateStr);
    _strtime( _timeStr );

	//replaces invalid character for file names
	replaceChar( _dateStr, '/', '-' );
	replaceChar( _timeStr, ':', ' ' );

	//creates the filename for decoded data
	strcpy(_outFile, "Predicted PreLaunch Data for Launch Date ");
	strcat(_outFile, _dateStr);
	strcat(_outFile, " Time ");
	strcat(_outFile, _timeStr);
	strcat(_outFile, ".txt");
	_fpOutPredicted.open ( _outFile, ios::app );

	_fpOutPredicted <<"Callsign: "
					<< _balloon->getCallSign() <<'\n'
					<<"Area of Parachute: "
					<< _balloon->getArea() <<'\n'
					<<"CD of Balloon: "
					<< _balloon->getDragBalloon() <<'\n'
					<<"CD of Parachute: "
					<< _balloon->getDragPara() <<'\n'
					<<"Mass of Balloon: "
					<< _balloon->getMassBalloon() <<'\n'
					<<"Mass of Payload: "
					<< _balloon->getMassPayload() <<'\n'
					<<"Mass of Helium: "
					<< _balloon->getMassHelium() <<'\n'
					<<"Lift in lbs: "
					<< _balloon->getLift() <<'\n'
					<<"Burst Diameter: "
					<< _balloon->getBurst() <<'\n'
					<<"---------------------" <<'\n';

	_fpOutPredicted <<"Air Density Intercept (b): "
					<< _bAir <<'\n'
					<<"Air Density Slope (m): "
					<< _mAir <<'\n'
					<<"Air Density at Launch: "
					<< air( _balloon->getLatestPoint().getAlt() ) <<'\n'
					<<"---------------------" <<'\n';
	_fpOutPredicted <<"Volume Intercept (b): "
					<< _bVol <<'\n'
					<<"Volume Slope (m): "
					<< _mVol <<'\n'
					<<"Volume at Launch: "
					<< volume ( _balloon->getLatestPoint().getAlt() ) <<'\n'
					<<"---------------------" <<'\n';
	_fpOutPredicted <<"\n*********************"
					<<"\nPrelaunch Prediction"
					<<"\n*********************" <<"\n\n";
}
Esempio n. 3
0
/***************************************************************
*
*	setAscentRate:
*	This function takes the previous two points and calculates 
*	the ascent rate
*
***************************************************************/
void Predictor::setAscentRatePre( )
{
	double airDen = air ( _balloon->getLatestPoint().getAlt() );
	double vol = volume ( _balloon->getLatestPoint().getAlt() );
	double totMass = ( _balloon->getMassPayload() + _balloon->getMassBalloon() );
	double areaBalloon = area( _balloon->getLatestPoint().getAlt() );
	totMass *= GRAVITY;
	double top = 2.0 * .85 * airDen * vol * GRAVITY;
	top = top - 2.0 * totMass;
	double bottom = _balloon->getDragBalloon() *  areaBalloon * airDen;
	top = top / bottom;
	_ascentRate = sqrt ( top );
}
Esempio n. 4
0
int main()
{
	int i, j;
	int res;
	int count = 0;
	scanf("%d %d", &N, &M);

	for (i = 0; i < N; i++)
	{
		for (j = 0; j < M; j++)
		{
			scanf("%d", &cheese[i][j]);
		}
	}

	while (1)
	{
		res = 0;
	
		memmove(visit, cheese, sizeof(cheese));
		air(0, 0);

		for (i = 0; i < N; i++)
		{
			for (j = 0; j < M; j++)
			{
				if (cheese[i][j] == 1)
				{
					bfs(i, j);
					res = 1;
				}
			}
		}
		if (res == 0) break;
		count++;
		
	}
	printf("%d\n", count);
}
Esempio n. 5
0
double TDielectricBase::get_refractive_index(double wavelen,
                                             double temperature,
                                             double relativePressure) const
{
    if (wavelen < m_MinWave || wavelen > m_MaxWave)
    {
        return 0.0;
    }

    double n_Tref;
    double Lamd = wavelen / 1000.0;

    // get refrative index at std. temp and std pressure
    n_Tref = get_refractive_index(wavelen);

    TAir air(m_temp);
    double n_air_std = air.get_refractive_index(wavelen);

    // glass refractive index vs vacuum at std temp.
    double n_abs_ref = n_Tref * n_air_std;

    double dltT = temperature - m_temp;

    double dltNabs = (pow(n_Tref, 2) - 1)/(2 * n_Tref)*
                     (m_D0*dltT + m_D1*pow(dltT,2) + m_D2*pow(dltT,3) +
                     (m_E0*dltT + m_E1*pow(dltT,2))/(pow(Lamd,2)-pow(m_Ltk,2)));

    // refractive at vacuum and temp.
    double n_abs_T = n_abs_ref + dltNabs;

    double n_air_T = air.get_refractive_index(wavelen, temperature,
                                              relativePressure);

    return  n_abs_T / n_air_T;

}
Esempio n. 6
0
int main(int argc, const char * argv[]) {
    
    //srand((unsigned int)(time(NULL)));
    
    Plane p;
    Airport air("John F. Kennedy Airport", "New York", 3);
    
    std::cout << "Welcome to " << air.getName() << ", " << air.getLocation() << ". \n\nWe currently fly to the following cities:\n";
    
    for(int i = 0; i < air.getDestinations().size(); i++)
        std::cout << air.getDestinations().at(i) << ", ";
    
    std::cout << std::endl;std::cout << std::endl;
    
    air.destinationFlights();
    
    std::cout << std::endl;
    
    Passenger passenger("Oyedotun","Oyesanmi", "Paris", SeatType::BUSINESS_CLASS);
    Booking book(passenger);
    book.seatAvailability(passenger, air);std::cout << std::endl;
    
    return 0;
}
Esempio n. 7
0
void Predictor::writeFileDesc ( )
{
	char _outFile[100];
	char _dateStr[9];
	char _timeStr[9];

	_strdate( _dateStr);
    _strtime( _timeStr );

	//replaces invalid character for file names
	replaceChar( _dateStr, '/', '-' );
	replaceChar( _timeStr, ':', ' ' );

	//creates the filename for decoded data
	strcpy(_outFile, "Predicted Descent Data for Launch Date ");
	strcat(_outFile, _dateStr);
	strcat(_outFile, " Time ");
	strcat(_outFile, _timeStr);
	strcat(_outFile, ".txt");
	_fpOutPredicted.open ( _outFile, ios::app );

	_fpOutPredicted <<"Callsign: "
					<< _balloon->getCallSign() <<'\n'
					<<"Area of Parachute: "
					<< _balloon->getArea() <<'\n'
					<<"CD of Balloon: "
					<< _balloon->getDragBalloon() <<'\n'
					<<"CD of Parachute: "
					<< _balloon->getDragPara() <<'\n'
					<<"Mass of Balloon: "
					<< _balloon->getMassBalloon() <<'\n'
					<<"Mass of Payload: "
					<< _balloon->getMassPayload() <<'\n'
					<<"Mass of Helium: "
					<< _balloon->getMassHelium() <<'\n'
					<<"Lift in lbs: "
					<< _balloon->getLift() <<'\n'
					<<"Burst Diameter: "
					<< _balloon->getBurst() <<'\n'
					<<"---------------------" <<'\n';

	_fpOutPredicted <<"Air Density Intercept (b): "
					<< _bAir <<'\n'
					<<"Air Density Slope (m): "
					<< _mAir <<'\n'
					<<"Air Density at Launch: "
					<< air( _balloon->getLatestPoint().getAlt() ) <<'\n'
					<<"---------------------" <<'\n';
	_fpOutPredicted <<"Volume Intercept (b): "
					<< _bVol <<'\n'
					<<"Volume Slope (m): "
					<< _mVol <<'\n'
					<<"Volume at Launch: "
					<< volume ( _balloon->getLatestPoint().getAlt() ) <<'\n'
					<<"---------------------" <<'\n';
	_fpOutPredicted <<"\n*********************"
					<<"\nBurst Prediction"
					<<"\n*********************" <<"\n\n";

	double altHold(0), timeHold(0);
	list<PredictedNode>::iterator move = _balloon->getPrePointDescent().begin();

	if ( _balloon->getPrePointDescent().size() > 1 )
	{
		while ( move != _balloon->getPrePointDescent().end() )
		{
			_fpOutPredicted <<"Predicted Altitude: "
							<<(*move).getAltPre() <<'\n'
							<<"Predicted Latitude: "
							<<(*move).getLatPre() <<'\n'
							<<"Predicted Longitude: "
							<<(*move).getLonPre() <<'\n'
							<<"Predicted Time: "
							<<(*move).getTimePre() <<'\n';
			altHold = (*move).getAltPre();
			timeHold = (*move).getTimePre();
			++move;
			if ( move != _balloon->getPrePointDescent().end() )
			{
				_fpOutPredicted <<"Ascent Rate: "
					<<getAscentRate() <<'\n';
			}
			_fpOutPredicted <<"---------------------" <<'\n';
		}
	}
}
Esempio n. 8
0
/***************************************************************
*
*	vPrimeDesc:
*	This function is used to solve the descent of the second order
*	equation
*
***************************************************************/
double Predictor::vPrimeDesc (double u , double v)
{
	return ( ( _balloon->getDragPara() * _balloon->getArea() * ( v * v ) * air( u ) ) / 
		( 2 * _balloon->getMassPayload() ) ) - GRAVITY;
}
Esempio n. 9
0
int main() {
	float a = air(10, 13.5);
}
Esempio n. 10
0
/* ------------------------------------------------------------------ run --- */
int MBASE::run()
{
	const int totalSamps = insamps + tapcount;
	int thisFrame = currentFrame();
	const int outChans = outputChannels();
	
	DBG1(printf("%s::run(): totalSamps = %d\n", name(), totalSamps));

	// this will return chunksamps' worth of input, even if we have
	// passed the end of the input (will produce zeros)

	getInput(thisFrame, framesToRun());

	DBG1(printf("getInput(%d, %d) called\n", thisFrame, framesToRun()));
	
	int bufsamps = getBufferSize();
	const int outputOffset = this->output_offset;
	
	// loop for required number of output samples
	const int frameCount = framesToRun();
	
	memset(this->outbuf, 0, frameCount * outChans * sizeof(BUFTYPE));
	
	int frame = 0;
	while (frame < frameCount) {
		// limit buffer size to end of current pull (chunksamps)
		if (frameCount - frame < bufsamps)
            bufsamps = max(0, frameCount - frame);

		thisFrame = currentFrame();	// store this locally for efficiency

		DBG1(printf("top of main loop: frame = %d  thisFrame = %d  bufsamps = %d\n",
                   frame, thisFrame, bufsamps));
		DBG(printf("input signal:\n"));
		DBG(PrintInput(&in[frame], bufsamps));
		
		// add signal to delay
		put_tap(thisFrame, &in[frame], bufsamps);

		// if processing input signal or flushing delay lines ... 

		if (thisFrame < totalSamps) {
			// limit buffer size of end of input data
			if (totalSamps - thisFrame < bufsamps)
				bufsamps = max(0, totalSamps - thisFrame);

			if ((tapcount = updatePosition(thisFrame)) < 0)
				RTExit(-1);

			DBG1(printf("  vector loop: bufsamps = %d\n", bufsamps));
			for (int ch = 0; ch < 2; ch++) {
				for (int path = 0; path < m_paths; path++) {
					Vector *vec = &m_vectors[ch][path];
					/* get delayed samps */
					get_tap(thisFrame, ch, path, bufsamps);
#if 0				
                    DBG(printf("signal [%d][%d] before filters:\n", ch, path));
					DBG(PrintSig(vec->Sig, bufsamps));
#endif
					/* air absorpt. filters */
         			air(vec->Sig, bufsamps, vec->Airdata);			
					/* wall absorpt. filters */
					if (path > 0)	// no filtering of direct signal
         				wall(vec->Sig, bufsamps, vec->Walldata);
					/* do binaural angle filters if necessary*/
					if (m_binaural)	{					
						fir(vec->Sig, thisFrame, g_Nterms[path], 
					    	vec->Fircoeffs, vec->Firtaps, bufsamps);
					}
                    DBG(printf("signal [%d][%d] before rvb:\n", ch, path));
                    DBG(PrintSig(vec->Sig, bufsamps));
//                    DBG(PrintSig(vec->Sig, bufsamps, SIG_THRESH));
		 		}
			}
			DBG(printf("summing vectors\n"));
			Vector *vec;
			register float *outptr = &this->outbuf[frame*outChans];
			// sum unscaled reflected paths as global input for RVB.
			for (int path = 0; path < m_paths; path++) {
				vec = &m_vectors[0][path];
				addScaleBufToOut(&outptr[2], vec->Sig, bufsamps, outChans, 1.0);
				vec = &m_vectors[1][path];
				addScaleBufToOut(&outptr[3], vec->Sig, bufsamps, outChans, 1.0);
			}
			if (!m_binaural) {
				// now do cardioid mike effect 
				// add scaled reflected paths to output as early response
				for (int path = 1; path < m_paths; path++) {
					vec = &m_vectors[0][path];
					addScaleBufToOut(&outptr[0], vec->Sig, bufsamps, outChans, vec->MikeAmp);
					vec = &m_vectors[1][path];
					addScaleBufToOut(&outptr[1], vec->Sig, bufsamps, outChans, vec->MikeAmp);
#if 0
					DBG(printf("early response L and R:\n"));
					DBG(PrintOutput(&outptr[0], bufsamps, outChans, SIG_THRESH));
					DBG(PrintOutput(&outptr[1], bufsamps, outChans, SIG_THRESH));
#endif
				}           
			}
			else {
           		// copy scaled, filtered reflected paths (reverb input) as the early reponse
				// to the output
				for (int ch = 0; ch < 2; ++ch) {
					float *dest = &outptr[ch];
					float *src = &outptr[ch+2];
					for (int n=0; n<bufsamps; ++n) {
						*dest = *src;
						dest += outChans;
						src += outChans;
					}
				}
			}
			/* add the direct signal into the output bus  */
			for (int n = 0; n < bufsamps; n++) {
				outptr[0] += m_vectors[0][0].Sig[n];
				outptr[1] += m_vectors[1][0].Sig[n];
				outptr += outChans;
			}
			DBG(printf("FINAL MIX LEFT CHAN:\n"));
			DBG(PrintOutput(&this->outbuf[frame*outChans], bufsamps, outChans));
		}		
		increment(bufsamps);
		frame += bufsamps;
		bufsamps = getBufferSize();		// update
		DBG1(printf("\tmain loop done.  thisFrame now %d\n", currentFrame()));
	}
	DBG1(printf("%s::run done\n\n", name()));
	return frame;
}
Esempio n. 11
0
air air::d_dt(const crd_t &y) const {
  return air((x_.at(1) * (y.at(0) - x_.at(0))), 0);
}
Esempio n. 12
0
/* ------------------------------------------------------------------ run --- */
int BASE::run()
{
	int	i = 0;
	double roomsig[2][BUFLEN], rvbsig[2][BUFLEN];

	const int totalSamps = insamps + tapcount;

	const int frameCount = framesToRun();
	
	DBG1(printf("%s::run(): totalSamps = %d\n", name(), totalSamps));

	// this will return frameCount' worth of input, even if we have
	// passed the end of the input (will produce zeros)

	getInput(cursamp, frameCount);

	DBG1(printf("getInput(%d, %d) called\n", cursamp, frameCount));
	
	int bufsamps = getBufferSize();
	
	// loop for required number of output samples

	while (i < frameCount) {
		// limit buffer size to end of current pull (chunksamps)
		if (frameCount - i < bufsamps)
			bufsamps = max(0, frameCount - i);

		DBG1(printf("top of main loop: i = %d  cursamp = %d  bufsamps = %d\n",
				   i, cursamp, bufsamps));
		DBG(printf("input signal:\n"));
		DBG(PrintInput(&in[i], bufsamps));
		
		// add signal to delay
		put_tap(cursamp, &in[i], bufsamps);

		// if processing input signal or flushing delay lines ... 

		if (cursamp < totalSamps) {
			// limit buffer size of end of input data
			if (totalSamps - cursamp < bufsamps)
				bufsamps = max(0, totalSamps - cursamp);
			
			if ((tapcount = updatePosition(cursamp)) < 0)
				return PARAM_ERROR;

			DBG1(printf("  inner loop: bufsamps = %d\n", bufsamps));
		
			for (int ch = 0; ch < 2; ch++) {
				for (int path = 0; path < 13; path++) {
					Vector *vec = &m_vectors[ch][path];
					DBG(printf("vector[%d][%d]:\n", ch, path));
					/* get delayed samps */
					get_tap(cursamp, ch, path, bufsamps);
					DBG(PrintSig(vec->Sig, bufsamps));   
					/* air absorpt. filters */
		 				air(vec->Sig, bufsamps, vec->Airdata);			
					/* wall absorpt. filters */
					if (path > 0)	// no filtering of direct signal
		 				wall(vec->Sig, bufsamps, vec->Walldata);
					/* do binaural angle filters if necessary*/
					if (m_binaural)						
						fir(vec->Sig, cursamp, g_Nterms[path], 
							vec->Fircoeffs, vec->Firtaps, bufsamps);
		   				// sum unscaled reflected paths as input for RVB.
					// first path is set; the rest are summed
					if (path == 1)
						copyBuf(&roomsig[ch][0], vec->Sig, bufsamps);			 
					else if (path > 1)
						addBuf(&roomsig[ch][0], vec->Sig, bufsamps);			 
					/* now do cardioid mike effect if not binaural mode */
					if (!m_binaural)
						scale(vec->Sig, bufsamps, vec->MikeAmp);
					DBG(printf("after final scale before rvb:\n"));
					DBG(PrintSig(vec->Sig, bufsamps, 0.1));
		 		}
				/* scale reverb input by amp factor */
				scale(&roomsig[ch][0], bufsamps, m_rvbamp);
			}
			/* run 1st and 2nd generation paths through reverberator */
 			for (int n = 0; n < bufsamps; n++) {
				if (m_rvbamp != 0.0) {
					double rmPair[2];
					double rvbPair[2];
					rmPair[0] = roomsig[0][n];
					rmPair[1] = roomsig[1][n];
					RVB(rmPair, rvbPair, cursamp + n);
					rvbsig[0][n] = rvbPair[0];
					rvbsig[1][n] = rvbPair[1];
				}
				else
					rvbsig[0][n] = rvbsig[1][n] = 0.0;
			}
			DBG(printf("summing vectors\n"));
			if (!m_binaural) {
		   		// re-sum scaled direct and reflected paths as early response
				// first path is set; the rest are summed
				for (int path = 0; path < 13; path++) {
					if (path == 0) {
						copyBuf(&roomsig[0][0], m_vectors[0][path].Sig, bufsamps);
						copyBuf(&roomsig[1][0], m_vectors[1][path].Sig, bufsamps);
					}		   
					else {
						addBuf(&roomsig[0][0], m_vectors[0][path].Sig, bufsamps);
						addBuf(&roomsig[1][0], m_vectors[1][path].Sig, bufsamps);
					}
				}		  
			}
			DBG(printf("left signal:\n"));
			DBG(PrintSig(roomsig[0], bufsamps, 0.1));
			DBG(printf("right signal:\n"));
			DBG(PrintSig(roomsig[1], bufsamps, 0.1));
			/* sum the early response & reverbed sigs  */
			register float *outptr = &this->outbuf[i*2];
			for (int n = 0; n < bufsamps; n++) {
				*outptr++ = roomsig[0][n] + rvbsig[0][n];
				*outptr++ = roomsig[1][n] + rvbsig[1][n];
			}
			DBG(printf("FINAL MIX:\n"));
			DBG(PrintInput(&this->outbuf[i], bufsamps));
		}

		else {		 /* flushing reverb */
			// this is the current location in the main output buffer
			// to write to now
			register float *outptr = &this->outbuf[i*2];
			DBG1(printf("  flushing reverb: i = %d, bufsamps = %d\n", i, bufsamps));
			for (int n = 0; n < bufsamps; n++) {
				if (m_rvbamp > 0.0) {
					double rmPair[2];
					double rvbPair[2];
					rmPair[0] = 0.0;
					rmPair[1] = 0.0;
					RVB(rmPair, rvbPair, cursamp + n);
					*outptr++ = rvbPair[0];
					*outptr++ = rvbPair[1];
				}
				else {
					*outptr++ = 0.0;
					*outptr++ = 0.0;
				}
			}
		}
		cursamp += bufsamps;
		i += bufsamps;
		bufsamps = getBufferSize();		// update
	}
	DBG1(printf("%s::run done\n\n", name()));
	return i;
}