当前位置: 首页>>代码示例>>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;未经允许,请勿转载。