예제 #1
0
// Returns the coplanar step capacitances per unit length.
void cpwstep::calcCends (nr_double_t frequency,
			 nr_double_t& C1, nr_double_t& C2) {

  // get properties of substrate and coplanar step
  nr_double_t W1 = getPropertyDouble ("W1");
  nr_double_t W2 = getPropertyDouble ("W2");
  nr_double_t s  = getPropertyDouble ("S");
  nr_double_t s1 = (s - W1) / 2;
  nr_double_t s2 = (s - W2) / 2;
  substrate * subst = getSubstrate ();
  nr_double_t er = subst->getPropertyDouble ("er");
  nr_double_t h  = subst->getPropertyDouble ("h");
  nr_double_t t  = subst->getPropertyDouble ("t");
  int backMetal  = !strcmp (getPropertyString ("Backside"), "Metal");

  nr_double_t ZlEff, ErEff, ZlEffFreq, ErEffFreq;
  cpwline::analyseQuasiStatic (W1, s1, h, t, er, backMetal, ZlEff, ErEff);
  cpwline::analyseDispersion  (W1, s1, h, er, ZlEff, ErEff, frequency,
			       ZlEffFreq, ErEffFreq);
  C1 = ErEffFreq / C0 / ZlEffFreq;
  cpwline::analyseQuasiStatic (W2, s2, h, t, er, backMetal, ZlEff, ErEff);
  cpwline::analyseDispersion  (W2, s2, h, er, ZlEff, ErEff, frequency,
			       ZlEffFreq, ErEffFreq);
  C2 = ErEffFreq / C0 / ZlEffFreq;
}
예제 #2
0
파일: mscross.cpp 프로젝트: Freecore/qucs
nr_double_t mscross::capCorrection (nr_double_t W, nr_double_t f) {
  substrate * subst = getSubstrate ();
  nr_double_t er = subst->getPropertyDouble ("er");
  nr_double_t h  = subst->getPropertyDouble ("h");
  nr_double_t t  = subst->getPropertyDouble ("t");
  char * SModel = getPropertyString ("MSModel");
  char * DModel = getPropertyString ("MSDispModel");
  nr_double_t Zl1, Er1, Zl2, Er2;
  nr_double_t ZlEff, ErEff, WEff;
  msline::analyseQuasiStatic (W, h, t, 9.9, SModel, ZlEff, ErEff, WEff);
  msline::analyseDispersion  (W, h, 9.9, ZlEff, ErEff, f, DModel,
                              Zl1, Er1);
  msline::analyseQuasiStatic (W, h, t, er, SModel, ZlEff, ErEff, WEff);
  msline::analyseDispersion  (W, h, er, ZlEff, ErEff, f, DModel,
                              Zl2, Er2);
  return Zl1 / Zl2 * sqrt (Er2 / Er1);
}
예제 #3
0
파일: msopen.cpp 프로젝트: Freecore/qucs
nr_complex_t msopen::calcY (nr_double_t frequency) {

  /* how to get properties of this component, e.g. W */
  nr_double_t W = getPropertyDouble ("W");
  char * SModel = getPropertyString ("MSModel");
  char * DModel = getPropertyString ("MSDispModel");
  char * Model  = getPropertyString ("Model");

  /* how to get properties of the substrate, e.g. Er, H */
  substrate * subst = getSubstrate ();
  nr_double_t er    = subst->getPropertyDouble ("er");
  nr_double_t h     = subst->getPropertyDouble ("h");
  nr_double_t t     = subst->getPropertyDouble ("t");

  /* local variables */
  nr_complex_t y;
  nr_double_t o = 2 * M_PI * frequency;

  /* Alexopoulos and Wu */
  if (!strcmp (Model, "Alexopoulos")) {
    nr_double_t ZlEff, ErEff, WEff, ZlEffFreq, ErEffFreq;
    msline::analyseQuasiStatic (W, h, t, er, SModel, ZlEff, ErEff, WEff);
    msline::analyseDispersion  (WEff, h, er, ZlEff, ErEff, frequency, DModel,
				ZlEffFreq, ErEffFreq);

    if (fabs (er - 9.9) > 0.2) {
      logprint (LOG_ERROR, "WARNING: Model for microstrip open end defined "
		"for er = 9.9 (er = %g)\n", er);
    }

    nr_double_t c1, c2, l2, r2;
    c1 = (1.125 * tanh (1.358 * W / h) - 0.315) *
      h / 2.54e-5 / 25 / ZlEffFreq * 1e-12;
    c2 = (6.832 * tanh (0.0109 * W / h) + 0.919) *
      h / 2.54e-5 / 25 / ZlEffFreq * 1e-12;
    l2 = (0.008285 * tanh (0.5665 * W / h) + 0.0103) *
      h / 2.54e-5 / 25 * ZlEffFreq * 1e-9;
    r2 = (1.024 * tanh (2.025 * W / h)) * ZlEffFreq;
    y = rect (0, c1 * o) + 1.0 / rect (r2, l2 * o - 1 / c2 / o);
  }
  else {
    nr_double_t c = calcCend (frequency, W, h, t, er, SModel, DModel, Model);
    y = rect (0, c * o);
  }
  return y;
}
예제 #4
0
void digisource::initDC (void) {
  char * init = getPropertyString ("init");
  nr_double_t v = getPropertyDouble ("V");
  bool lo = !strcmp (init, "low");
  allocMatrixMNA ();
  setC (VSRC_1, NODE_1, 1.0);
  setB (NODE_1, VSRC_1, 1.0);
  setD (VSRC_1, VSRC_1, 0.0);
  setE (VSRC_1, lo ? 0 : v);
}
예제 #5
0
void digisource::calcTR (nr_double_t t) {
  char * init = getPropertyString ("init");
  nr_double_t v = getPropertyDouble ("V");
  vector * values = getPropertyVector ("times");
  bool lo = !strcmp (init, "low");
  nr_double_t ti = 0;

  t = t - T * floor (t / T);
  for (int i = 0; i < values->getSize (); i++) {
    ti += real (values->get (i));
    if (t >= ti) lo = !lo; else break;
  }

  setE (VSRC_1, lo ? 0 : v);
}
예제 #6
0
void EdoChatWindowMessage::applyOptions()
{
	if (getPropertyBool(EWND_MESSAGE_SHOW_AVATAR, true))
	{
		avatar->setVisible (true);
	}
	else
	{
		avatar->setVisible (false);
	}

	messageLabel->setColour (TextEditor::highlightedTextColourId, getPropertyColour(EWND_MESSAGE_FONT_COLOUR, Colours::black));
	messageLabel->applyFontToAllText ( EdoRestoreFont (getPropertyString(EWND_MESSAGE_FONT), Font(14)) );
	constructMessage();
}
/* This is the AC netlist solver.  It prepares the circuit list for
   each requested frequency and solves it then. */
int acsolver::solve (void) {
  runs++;

  // run additional noise analysis ?
  noise = !strcmp (getPropertyString ("Noise"), "yes") ? 1 : 0;

  // create frequency sweep if necessary
  if (swp == NULL) {
    swp = createSweep ("acfrequency");
  }

  // initialize node voltages, first guess for non-linear circuits and
  // generate extra circuits if necessary
  init ();
  setCalculation ((calculate_func_t) &calc);
  solve_pre ();

  swp->reset ();
  for (int i = 0; i < swp->getSize (); i++) {
    freq = swp->next ();
    if (progress) logprogressbar (i, swp->getSize (), 40);

#if DEBUG && 0
    logprint (LOG_STATUS, "NOTIFY: %s: solving netlist for f = %e\n",
	      getName (), (double) freq);
#endif
    
    // start the linear solver
    eqnAlgo = ALGO_LU_DECOMPOSITION;
    solve_linear ();

    // compute noise if requested
    if (noise) solve_noise ();

    // save results
    saveAllResults (freq);
  }
  solve_post ();
  if (progress) logprogressclear (40);
  return 0;
}
예제 #8
0
/*!\brief Get properties from model.
 * Get properties and fill the class.
 *  
 *  \todo check values
 */
void bondwire::getProperties (void) {
  unsigned int i;

  R = 0;
  l = getPropertyDouble ("L");
  d = getPropertyDouble ("D");
  h = getPropertyDouble ("H");
  rho = getPropertyDouble ("rho");
  mur = getPropertyDouble ("mur");
  
  /* model used */
  char * Model  = getPropertyString ("Model");
  if (Model == NULL) {
    model = FREESPACE;
    logprint (LOG_STATUS, "Model is not specified force FREESPACE\n");
  } else {
    model = (enum bondwiremodel) -1;
    for (i = 0 ; i < ARRAY_SIZE (modeltable); i++) {
      if (!strcasecmp (modeltable[i].name, Model))
	model = modeltable[i].model;
    }

    if (model == -1) 
      /* XXXX: how to abort ? */
      logprint (LOG_ERROR, "Model %s not defined\n", Model);
  }

  /* For noise */
  temp = getPropertyDouble ("Temp");

  /* how to get properties of the substrate, e.g. Er, H */
  substrate * subst = getSubstrate ();
  nr_double_t er    = subst->getPropertyDouble ("er");
  nr_double_t h     = subst->getPropertyDouble ("h");
  nr_double_t t     = subst->getPropertyDouble ("t");
  
  /* Not yet used */
  (void) er;
  (void) h;
  (void) t;
}
예제 #9
0
const int EdoChatWindowMessage::getMessageHeight(const int parentWidth, const Justification justification)
{
	GlyphArrangement messageGlyphs;
	float top,left,right,bottom;

	applyOptions();
	messageGlyphs.clear();

	messageGlyphs.addJustifiedText (
										EdoRestoreFont (getPropertyString(EWND_MESSAGE_FONT), Font(14)), 
										messageLabel->getText(), 
										0, 
										0, 
										(float)parentWidth, 
										justification
									);

	messageGlyphs.getBoundingBox (0, -1, left, top, right, bottom, true);

	messageHeight = roundFloatToInt ((bottom - top) + SPACER);

	// Log (String::formatted (T("EdoChatWindowMessage::getMessageHeight parentWidth: %d height: %d"), parentWidth, messageHeight));

	if (avatar->isVisible())
	{
		if (messageHeight < (avatar->getHeight()+16))
		{
			messageHeight = avatar->getHeight()+16;
			return (messageHeight+SPACER);
		}
		else
		{
			return (messageHeight+SPACER);
		}
	}
	else
	{
		return (messageHeight+SPACER);
	}
}
예제 #10
0
 /*
  * Get the text on the back button.
  * @return The text displayed ont he back button.
  */
 MAUtil::String NavigationBar::getBackButtonTitle()
 {
     return getPropertyString(MAW_NAV_BAR_BACK_BTN);
 }
예제 #11
0
 /**
  * Get a local notification property as a string.
  * @param property A string representing which property to get.
  * @return The property value.
  */
 MAUtil::String LocalNotification::getPropertyString(
     const MAUtil::String& property) const
 {
     int resultCode;
     return getPropertyString(property,resultCode);
 }
예제 #12
0
 /*
  * Get the text on the back button.
  * @return The text displayed ont he back button.
  */
 MAUtil::String NavigationBar::getBackBtnText() const
 {
     return getPropertyString(MAW_NAV_BAR_BACK_BTN);
 }
예제 #13
0
/* This is the initialisation function for the slaved transient
   netlist solver. It prepares the circuit for simulation. */
int e_trsolver::init (nr_double_t start, nr_double_t firstdelta, int mode)
{
    // run the equation solver for the netlist
    this->getEnv()->runSolver();

    int error = 0;
    const char * const solver = getPropertyString ("Solver");
    relaxTSR = !strcmp (getPropertyString ("relaxTSR"), "yes") ? true : false;
    initialDC = !strcmp (getPropertyString ("initialDC"), "yes") ? true : false;
    // fetch simulation properties
    MaxIterations = getPropertyInteger ("MaxIter");
    reltol = getPropertyDouble ("reltol");
    abstol = getPropertyDouble ("abstol");
    vntol = getPropertyDouble ("vntol");

    runs++;
    saveCurrent = current = 0;
    stepDelta = -1;
    converged = 0;
    fixpoint = 0;
    lastsynctime = 0.0;
    statRejected = statSteps = statIterations = statConvergence = 0;

    // Choose a solver.
    if (!strcmp (solver, "CroutLU"))
        eqnAlgo = ALGO_LU_DECOMPOSITION;
    else if (!strcmp (solver, "DoolittleLU"))
        eqnAlgo = ALGO_LU_DECOMPOSITION_DOOLITTLE;
    else if (!strcmp (solver, "HouseholderQR"))
        eqnAlgo = ALGO_QR_DECOMPOSITION;
    else if (!strcmp (solver, "HouseholderLQ"))
        eqnAlgo = ALGO_QR_DECOMPOSITION_LS;
    else if (!strcmp (solver, "GolubSVD"))
        eqnAlgo = ALGO_SV_DECOMPOSITION;

    // Perform initial DC analysis.
    if (initialDC)
    {
        error = dcAnalysis ();
        if (error)
            return -1;
    }

    // Initialize transient analysis.
    setDescription ("transient");
    initETR (start, firstdelta, mode);
    setCalculation ((calculate_func_t) &calcTR);
    solve_pre ();

    // Recall the DC solution.
    recallSolution ();

    // Apply the nodesets and adjust previous solutions.
    applyNodeset (false);
    fillSolution (x);
    fillLastSolution (x);

    // Tell integrators to be initialized.
    setMode (MODE_INIT);

    // reset the circuit status to not running so the histories
    // etc will be reinitialised on the first time step
    running = 0;
    rejected = 0;
    if (mode == ETR_MODE_ASYNC)
    {
        delta /= 10;

    }
    else if (mode == ETR_MODE_SYNC)
    {
        //lastsynctime = start - delta;
    }
    else
    {
        qucs::exception * e = new qucs::exception (EXCEPTION_UNKNOWN_ETR_MODE);
        e->setText ("Unknown ETR mode.");
        throw_exception (e);
        return -2;
    }
    fillState (dState, delta);
    adjustOrder (1);

    storeHistoryAges ();

    return 0;

}
예제 #14
0
 /*
  * Get the title.
  * @return The displayed title.
  */
 MAUtil::String NavigationBar::getTitle() const
 {
     return getPropertyString(MAW_NAV_BAR_TITLE);
 }
예제 #15
0
    /**
     * Get the checked state of the radio button.
     * @return true if the radio button is checked, false otherwise.
     */
    bool RadioButton::isChecked()
    {
		MAUtil::String state = MAUtil::lowerString(getPropertyString(MAW_RADIO_BUTTON_CHECKED));
		return ( strcmp( state.c_str(),"true") == 0 ? true : false );
    }
예제 #16
0
    /**
     * Get the displayed text.
     * @return The displayed text.
     */
    MAUtil::String RadioButton::getText()
    {
		return getPropertyString(MAW_RADIO_BUTTON_TEXT);
    }
예제 #17
0
파일: dcsolver.cpp 프로젝트: Freecore/qucs
/* This is the DC netlist solver.  It prepares the circuit list and
   solves it then. */
int dcsolver::solve (void) {
  // fetch simulation properties
  saveOPs |= !strcmp (getPropertyString ("saveOPs"), "yes") ? SAVE_OPS : 0;
  saveOPs |= !strcmp (getPropertyString ("saveAll"), "yes") ? SAVE_ALL : 0;
  char * solver = getPropertyString ("Solver");

  // initialize node voltages, first guess for non-linear circuits and
  // generate extra circuits if necessary
  init ();
  setCalculation ((calculate_func_t) &calc);

  // start the iterative solver
  solve_pre ();

  // choose a solver
  if (!strcmp (solver, "CroutLU"))
    eqnAlgo = ALGO_LU_DECOMPOSITION_CROUT;
  else if (!strcmp (solver, "DoolittleLU"))
    eqnAlgo = ALGO_LU_DECOMPOSITION_DOOLITTLE;
  else if (!strcmp (solver, "HouseholderQR"))
    eqnAlgo = ALGO_QR_DECOMPOSITION;
  else if (!strcmp (solver, "HouseholderLQ"))
    eqnAlgo = ALGO_QR_DECOMPOSITION_LS;
  else if (!strcmp (solver, "GolubSVD"))
    eqnAlgo = ALGO_SV_DECOMPOSITION;

  // local variables for the fallback thingies
  int retry = -1, error, fallback = 0, preferred;
  int helpers[] = {
    CONV_SourceStepping,
    CONV_GMinStepping,
    CONV_SteepestDescent,
    CONV_LineSearch,
    CONV_Attenuation,
    -1 };

  // is a certain convergence helper requested?
  char * helper = getPropertyString ("convHelper");
  convHelper = CONV_None;
  if (!strcmp (helper, "LineSearch")) {
    convHelper = CONV_LineSearch;
  } else if (!strcmp (helper, "SteepestDescent")) {
    convHelper = CONV_SteepestDescent;
  } else if (!strcmp (helper, "Attenuation")) {
    convHelper = CONV_Attenuation;
  } else if (!strcmp (helper, "gMinStepping")) {
    convHelper = CONV_GMinStepping;
  } else if (!strcmp (helper, "SourceStepping")) {
    convHelper = CONV_SourceStepping;
  }
  preferred = convHelper;

  if (!subnet->isNonLinear ()) {
    // Start the linear solver.
    convHelper = CONV_None;
    error = solve_linear ();
  }
  else do {
    // Run the DC solver once.
    try_running () {
      applyNodeset ();
      error = solve_nonlinear ();
#if DEBUG
      if (!error) {
	logprint (LOG_STATUS,
		  "NOTIFY: %s: convergence reached after %d iterations\n",
		  getName (), iterations);
      }
#endif /* DEBUG */
      if (!error) retry = -1;
    }
    // Appropriate exception handling.
    catch_exception () {
    case EXCEPTION_NO_CONVERGENCE:
      pop_exception ();
      if (preferred == helpers[fallback] && preferred) fallback++;
      convHelper = helpers[fallback++];
      if (convHelper != -1) {
	logprint (LOG_ERROR, "WARNING: %s: %s analysis failed, using fallback "
		  "#%d (%s)\n", getName (), getDescription (), fallback,
		  getHelperDescription ());
	retry++;
	restart ();
      }
      else {
	retry = -1;
      }
      break;
    default:
      // Otherwise return.
      estack.print ();
      error++;
      break;
    }
  } while (retry != -1);

  // save results and cleanup the solver
  saveOperatingPoints ();
  saveResults ("V", "I", saveOPs);

  solve_post ();
  return 0;
}
예제 #18
0
/* Goes through the list of circuit objects and runs its initTR()
   function. */
void e_trsolver::initETR (nr_double_t start, nr_double_t firstdelta, int mode)
{
    const char * const IMethod = getPropertyString ("IntegrationMethod");
    //nr_double_t start = getPropertyDouble ("Start");
    //nr_double_t stop = start + firstdelta;
    //nr_double_t points = 1.0;

    // fetch corrector integration method and determine predicor method
    corrMaxOrder = getPropertyInteger ("Order");
    corrType = CMethod = correctorType (IMethod, corrMaxOrder);
    predType = PMethod = predictorType (CMethod, corrMaxOrder, predMaxOrder);
    corrOrder = corrMaxOrder;
    predOrder = predMaxOrder;

    // initialize step values
    if (mode == ETR_MODE_ASYNC){
        delta = getPropertyDouble ("InitialStep");
        deltaMin = getPropertyDouble ("MinStep");
        deltaMax = getPropertyDouble ("MaxStep");
        if (deltaMax == 0.0)
            deltaMax = firstdelta; // MIN ((stop - start) / (points - 1), stop / 200);
        if (deltaMin == 0.0)
            deltaMin = NR_TINY * 10 * deltaMax;
        if (delta == 0.0)
            delta = firstdelta; // MIN (stop / 200, deltaMax) / 10;
        if (delta < deltaMin) delta = deltaMin;
        if (delta > deltaMax) delta = deltaMax;
    }
    else if (mode == ETR_MODE_SYNC)
    {
        delta = firstdelta;
        deltaMin = NR_TINY * 10;
        deltaMax =  std::numeric_limits<nr_double_t>::max() / 10;
    }

    // initialize step history
    setStates (2);
    initStates ();
    // initialise the history of states, setting them all to 'delta'
    fillState (dState, delta);

    // copy the initialised states to the 'deltas' array
    saveState (dState, deltas);
    // copy the deltas to all the circuits
    setDelta ();
    // set the initial corrector and predictor coefficients
    calcCorrectorCoeff (corrType, corrOrder, corrCoeff, deltas);
    calcPredictorCoeff (predType, predOrder, predCoeff, deltas);

    // initialize history of solution vectors (solutions)
    for (int i = 0; i < 8; i++)
    {
        // solution contains the last sets of node voltages and branch
        // currents at each of the last 8 'deltas'.
        // Note for convenience the definition:
        //   #define SOL(state) (solution[(int) getState (sState, (state))])
        // is provided and used elsewhere to update the solutions
        solution[i] = new tvector<nr_double_t>;
        setState (sState, (nr_double_t) i, i);
        lastsolution[i] = new tvector<nr_double_t>;
    }

    // Initialise history tracking for asynchronous solvers
    // See acceptstep_async and rejectstep_async for more
    // information
    lastasynctime = start;
    saveState (dState, lastdeltas);
    lastdelta = delta;

    // tell circuit elements about the transient analysis
    circuit *c, * root = subnet->getRoot ();
    for (c = root; c != NULL; c = (circuit *) c->getNext ())
        initCircuitTR (c);
    // also initialize the created circuit elements
    for (c = root; c != NULL; c = (circuit *) c->getPrev ())
        initCircuitTR (c);
}