__ses_path_a_diode()
authoryu.dongliang <18588496441@163.com>
Mon, 13 Nov 2023 05:53:23 +0000 (13:53 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 13 Nov 2023 05:53:23 +0000 (13:53 +0800)
ses_step_jr.c
ses_step_va_diode.c
ses_steps.c

index 4e2dfb3669e1c3658dd5cb29ac773447c070129e..4cfc1ec8f8e90135599b1b5fe5e35612b0cdbff2 100644 (file)
@@ -64,8 +64,8 @@ void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1
                        p1 = path->pins->data[j - 1];
                        c1 = f->components[p1->cid];
 
-                       if (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_E == p1->id)
-                               p1 = path->pins->data[j - 2];
+//                     if (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_E == p1->id)
+//                             p1 = path->pins->data[j - 2];
                } else {
                        *r  = 0;
                        *jr = 0;
index fef78f8d26654066e00f152562fd0b883804ce07..62b81924c848476670407c3c69facc520613fc07 100644 (file)
@@ -199,6 +199,62 @@ void __ses_path_dr_reverse(ScfEfunction* f, ses_path_t* path, int i, int j, doub
        }
 }
 
+static void __ses_path_a_diode(ScfEfunction* f, ses_path_t* path, int k, double* a, double* ja)
+{
+       ses_info_t* info;
+
+       ScfEpin*    p0 = path->pins->data[0];
+       ScfEpin*    p1 = path->pins->data[path->pins->size - 1];
+       ScfEpin*    pi;
+       ScfEpin*    pj;
+
+       double v  = p0->v  - p1->v;
+       double jv = p0->jv - p1->jv;
+
+       double r  = 0;
+       double jr = 0;
+
+       int i = 0;
+       int j;
+
+       for (j = k; j < path->diodes->size; j++) {
+               info      = path->diodes->data[j];
+               pi        = path->pins->data[i];
+               pj        = path->pins->data[info->i];
+
+               v  -= info->n_diodes * SCF_EDA_V_Diode_ON;
+               v  -= info->n_NPNs   * SCF_EDA_V_NPN_ON;
+
+               double _r;
+               double _jr;
+
+               __ses_path_pr(f, path, i, info->i, NULL, &_r, &_jr);
+
+               r  += _r;
+               jr += _jr;
+
+               scf_logi("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg, _r: %lg\n", pi->cid, pi->id, pj->cid, pj->id, r, v, _r);
+
+               i = info->j;
+       }
+
+       scf_logd("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg\n", p0->cid, p0->id, p1->cid, p1->id, r, v);
+
+       if (i  < path->pins->size - 1) {
+               pi = path->pins->data[i];
+
+               r  += p1->sr  - p1->r  - pi->pr;
+               jr += p1->jsr - p1->jr - pi->jpr;
+
+               scf_logd("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg, pi->pr: %lg, p1->sr: %lg, p1->r: %lg\n",
+                               pi->cid, pi->id, p1->cid, p1->id, r, v, pi->pr, p1->sr, p1->r);
+       }
+
+       ses_ur_i(a, ja, v, jv, r, jr);
+
+       scf_loge("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg, a: %lg\n\n", p0->cid, p0->id, p1->cid, p1->id, r, v, *a);
+}
+
 static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
 {
        ses_path_t*    child;
@@ -243,50 +299,15 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
        double a;
        double ja;
 
-       i = 0;
-
-       for (j = 0; j < path->diodes->size; j++) {
-               info      = path->diodes->data[j];
-               pi        = path->pins->data[i];
-               pj        = path->pins->data[info->i];
-
-               v  -= info->n_diodes * SCF_EDA_V_Diode_ON;
-               v  -= info->n_NPNs   * SCF_EDA_V_NPN_ON;
-
-               double _r;
-               double _jr;
-
-               __ses_path_pr(f, path, i, info->i, NULL, &_r, &_jr);
-
-               r  += _r;
-               jr += _jr;
-
-               scf_logi("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg, _r: %lg\n", pi->cid, pi->id, pj->cid, pj->id, r, v, _r);
-
-               i = info->j;
-       }
-
-       scf_logd("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg\n", p0->cid, p0->id, p1->cid, p1->id, r, v);
-
-       if (i  < path->pins->size - 1) {
-               pi = path->pins->data[i];
-
-               r  += p1->sr  - p1->r  - pi->pr;
-               jr += p1->jsr - p1->jr - pi->jpr;
-
-               scf_logd("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg, pi->pr: %lg, p1->sr: %lg, p1->r: %lg\n",
-                               pi->cid, pi->id, p1->cid, p1->id, r, v, pi->pr, p1->sr, p1->r);
-       }
-
-       ses_ur_i(&a, &ja, v, jv, r, jr);
-
-       scf_loge("c%ldp%ld--c%ldp%ld, r: %lg, v: %lg, a: %lg\n\n", p0->cid, p0->id, p1->cid, p1->id, r, v, a);
+       __ses_path_a_diode(f, path, 0, &a, &ja);
 
        path->a  = a;
        path->ja = ja;
 
        i = 0;
 
+       scf_logi("**************\n");
+
        for (j = 0; j < path->diodes->size; j++) {
                info      = path->diodes->data[j];
                pi        = path->pins->data[info->i];
@@ -300,6 +321,8 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                pi->a  = a;
                pi->ja = ja;
 
+               scf_logi("j: %d, ---------------\n", j);
+
                __ses_path_pr(f, path, i, info->i, NULL, &r, &jr);
 
                ses_ir_u(&v, &jv, a, ja, r, jr);
@@ -334,6 +357,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                                info->i, info->j, pi->cid, pi->id, pj->cid, pj->id, pi->v, pj->v, pi->a);
 
                __ses_path_dr_forward(f, path, info->i, info->j, pi->a, pi->ja);
+               printf("\n");
        }
 
        return 0;
index 204bbab7b4fa979f9735dc2d6e97ebde6dd05495..27623ed1a35347bb17b9332f4904bda6ae96e3b8 100644 (file)
@@ -43,7 +43,7 @@ static ses_step_t*  ses_steps_1[] =
 
        &ses_step_va_diode,
        &ses_step_va_transistor,
-#if 1
+#if 0
        &ses_step_jr,
        &ses_step_va,
        &ses_step_va_bridge,