#include "peg_pic.h"


/************** Initialization of cirquit parameters ***************/

void incirq() {

	/* Deciding which circuit solver to use.. */

	if(extc < 1e-30) {
		/* OPEN CIRCUIT: when C tends to 0.0 */
		if (fabs(dcbias)+fabs(ramp)+fabs(acbias) > 0) {
			puts("START: Active external source is ignored since C < 1E-30\n");
		}

		bcptr = bc1;
		circuitptr = circuit1;
		nstrt = 0;
		b0 = -1.0;
		cappa = 1;                 /* cappa is for speeding up the run */
		
	} else if(src== 'I' || src== 'i') {
		/* CURRENT SOURCE: when current source is applied */       
		bcptr = bc2;
		circuitptr = circuit2;
		nstrt = 0;
		b0 = -1.0;
		cappa = 1;
		
	} else if(extl < 1e-30 && extr < 1e-30 && extc >= 1e5*epsilon*area/length) {
		/* SHORT CIRCUIT: when L=R=0.0 and C tends to infinity */
		bcptr = bc3;
		circuitptr = circuit3;
		nstrt = 1;
		b0 = -2.0;
		cappa = 0;
		
	} else {
		/* The GENERAL CASE (with external voltage source) */
		bcptr = bc4;
		circuitptr = circuit4;
		nstrt = 0;
		b0 = 2.25*extl/dt/dt + 1.5*extr/dt + 1/extc;
		b0 = -(1 + dx/b0/area/epsilon);
		cappa = 0;
	}
} /* End of INCIRQ */

/*********************************************************************/

