當前位置: 首頁>>代碼示例>>C#>>正文


C# Circuit.panic方法代碼示例

本文整理匯總了C#中Circuit.panic方法的典型用法代碼示例。如果您正苦於以下問題:C# Circuit.panic方法的具體用法?C# Circuit.panic怎麽用?C# Circuit.panic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Circuit的用法示例。


在下文中一共展示了Circuit.panic方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: beginStep

 public override void beginStep(Circuit sim)
 {
     // calculate voltages, currents sent over wire
     if(voltageL == null) {
         sim.panic("Transmission line delay too large!", this);
         return;
     }
     voltageL[ptr] = lead_volt[2] - lead_volt[0] + lead_volt[2] - lead_volt[4];
     voltageR[ptr] = lead_volt[3] - lead_volt[1] + lead_volt[3] - lead_volt[5];
     // System.out.println(volts[2] + " " + volts[0] + " " +
     // (volts[2]-volts[0]) + " " + (imped*current1) + " " + voltageL[ptr]);
     /*
      * System.out.println("sending fwd  " + currentL[ptr] + " " + current1);
      * System.out.println("sending back " + currentR[ptr] + " " + current2);
      */
     // System.out.println("sending back " + voltageR[ptr]);
     ptr = (ptr + 1) % lenSteps;
 }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:18,代碼來源:TransLineElm.cs

示例2: step

 public override void step(Circuit sim)
 {
     double[] vs = new double[3];
     vs[0] = lead_volt[0];
     vs[1] = lead_volt[1];
     vs[2] = lead_volt[2];
     if(vs[1] > lastv1 + .5) vs[1] = lastv1 + .5;
     if(vs[1] < lastv1 - .5) vs[1] = lastv1 - .5;
     if(vs[2] > lastv2 + .5) vs[2] = lastv2 + .5;
     if(vs[2] < lastv2 - .5) vs[2] = lastv2 - .5;
     int source = 1;
     int drain = 2;
     if((pnp ? -1 : 1) * vs[1] > (pnp ? -1 : 1) * vs[2]) {
         source = 2;
         drain = 1;
     }
     int gate = 0;
     double vgs = vs[gate] - vs[source];
     double vds = vs[drain] - vs[source];
     if(Math.Abs(lastv1 - vs[1]) > .01 || Math.Abs(lastv2 - vs[2]) > .01)
         sim.converged = false;
     lastv1 = vs[1];
     lastv2 = vs[2];
     double realvgs = vgs;
     double realvds = vds;
     vgs *= (pnp ? -1 : 1);
     vds *= (pnp ? -1 : 1);
     ids = 0;
     gm = 0;
     double Gds = 0;
     double beta = getBeta();
     if(vgs > .5 && this is JfetElm) {
         sim.panic("JFET is reverse biased!", this);
         return;
     }
     if(vgs < _threshold) {
         // should be all zero, but that causes a singular matrix,
         // so instead we treat it as a large resistor
         Gds = 1e-8;
         ids = vds * Gds;
         mode = 0;
     } else if(vds < vgs - _threshold) {
         // linear
         ids = beta * ((vgs - _threshold) * vds - vds * vds * .5);
         gm = beta * vds;
         Gds = beta * (vgs - vds - _threshold);
         mode = 1;
     } else {
         // saturation; Gds = 0
         gm = beta * (vgs - _threshold);
         // use very small Gds to avoid nonconvergence
         Gds = 1e-8;
         ids = 0.5 * beta * (vgs - _threshold) * (vgs - _threshold) + (vds - (vgs - _threshold)) * Gds;
         mode = 2;
     }
     double rs = -(pnp ? -1 : 1) * ids + Gds * realvds + gm * realvgs;
     sim.stampMatrix(lead_node[drain], lead_node[drain], Gds);
     sim.stampMatrix(lead_node[drain], lead_node[source], -Gds - gm);
     sim.stampMatrix(lead_node[drain], lead_node[gate], gm);
     sim.stampMatrix(lead_node[source], lead_node[drain], -Gds);
     sim.stampMatrix(lead_node[source], lead_node[source], Gds + gm);
     sim.stampMatrix(lead_node[source], lead_node[gate], -gm);
     sim.stampRightSide(lead_node[drain], rs);
     sim.stampRightSide(lead_node[source], -rs);
     if(source == 2 && (pnp ? -1 : 1) == 1 || source == 1 && (pnp ? -1 : 1) == -1)
         ids = -ids;
 }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:67,代碼來源:Mosfet.cs

示例3: step

        public override void step(Circuit sim)
        {
            if(voltageL == null) {
                sim.panic("Transmission line delay too large!", this);
                return;
            }

            sim.updateVoltageSource(lead_node[4], lead_node[0], voltSource1, -voltageR[ptr]);
            sim.updateVoltageSource(lead_node[5], lead_node[1], voltSource2, -voltageL[ptr]);

            if(Math.Abs(lead_volt[0]) > 1e-5 || Math.Abs(lead_volt[1]) > 1e-5) {
                sim.panic("Need to ground transmission line!", this);
                return;
            }
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:15,代碼來源:TransLineElm.cs


注:本文中的Circuit.panic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。