ses_step_va_diode.c
authoryu.dongliang <18588496441@163.com>
Wed, 6 Sep 2023 13:10:51 +0000 (21:10 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 6 Sep 2023 13:10:51 +0000 (21:10 +0800)
ses_step_jr.c
ses_step_va_diode.c

index 934317885fad7ee5e8bd1a0df8649fd67b9d2330..d56375d6bbe8946791c4dd7d874a396304258953 100644 (file)
@@ -131,8 +131,7 @@ static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
                                scf_logw("j: %d, c%ldp%ld, p->pr: %lg + j%lg, p->sr: %lg + j%lg\n", j, p->cid, p->id, p->pr, p->jpr, p->sr, p->jsr);
                        }
 
-                       scf_loge("child: %d, r: %lg, jr: %lg, r0: %lg, jr0: %lg, _r: %lg, _jr: %lg, dr: %lg, jdr: %lg\n\n",
-                                       child->index, child->r, child->jr, child->r0, child->jr0, _r, _jr, dr, jdr);
+                       scf_logw("child: %d, r: %lg, jr: %lg, dr: %lg, jdr: %lg\n\n", child->index, child->r, child->jr, dr, jdr);
                }
        }
 
index 1a4a8b3a3361f46b986f2ecd708afe2a08c3edd4..2bc7a029f0a3a8fa10c35c705d39e50e287d905e 100644 (file)
@@ -1,11 +1,8 @@
 #include"ses_core.h"
 
-static void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, ScfEpin* p1, double* a, double* ja)
+static void __ses_path_split_i(ses_path_t* path, ScfEpin* p0, ScfEpin* p1, ScfEline* el, double* a, double* ja)
 {
        ses_path_t*    child;
-       ScfEcomponent* c;
-       ScfEline*      el;
-       ScfEpin*       cp;
        ScfEpin*       cp0;
        ScfEpin*       cp1;
 
@@ -15,8 +12,6 @@ static void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, S
        double r  = p1->pr  - p0->pr;
        double jr = p1->jpr - p0->jpr;
 
-       el = f->elines[p0->lid];
-
        int j;
        for (j    = 0; j < path->childs->size; j++) {
                child =        path->childs->data[j];
@@ -34,17 +29,39 @@ static void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, S
 
                cp0->a  = child->a;
                cp0->ja = child->ja;
+               cp1->a  = child->a;
+               cp1->ja = child->ja;
 
                double cr;
                double jcr;
 
-               ses_ui_r(&cr, &jcr, v, jv, child->a, child->ja);
+               ses_ui_r(&cp1->dr, &cp1->jdr, v, jv, child->a, child->ja);
 
-               scf_loge("j: %d, c%ldp%ld, v: %lg + j%lg, child->r: %lg + j%lg, child->a: %lg + j%lg, cr: %lg + j%lg\n", j, cp0->cid, cp0->id,
-                               v, jv, child->r, child->jr, child->a, child->ja, cr, jcr);
+               cp1->dr  -= child->r;
+               cp1->jdr -= child->jr;
+
+               scf_loge("j: %d, c%ldp%ld, v: %lg + j%lg, child->r: %lg + j%lg, child->a: %lg + j%lg, el->a: %lg + j%lg, cp1->dr: %lg + j%lg\n", j, cp0->cid, cp0->id,
+                               v, jv, child->r, child->jr, child->a, child->ja, el->a, el->ja, cp1->dr, cp1->jdr);
        }
 }
 
+static void __ses_path_dr(ScfEpin* p0, ScfEpin* p1, ScfEpin* p)
+{
+       double v  = p0->v   - p1->v;
+       double jv = p0->jv  - p1->jv;
+
+       double r  = p1->sr  - p0->sr;
+       double jr = p1->jsr - p0->jsr;
+
+       ses_ui_r(&p->dr, &p->jdr, v, jv, p->a, p->ja);
+
+       scf_logd("c%ldp%ld, v: %lg + j%lg, r: %lg + j%lg, p->a: %lg + j%lg, p->dr: %lg + j%lg\n", p->cid, p->id,
+                       v, jv, r, jr, p->a, p->ja, p->dr, p->jdr);
+
+       p->dr  -= r;
+       p->jdr -= jr;
+}
+
 static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
 {
        ses_path_t*    child;
@@ -72,10 +89,11 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
 
        double v;
        double jv;
-       double a;
-       double ja;
-       double r;
-       double jr;
+
+       double pr;
+       double jpr;
+       double sr;
+       double jsr;
 
        for (i = 1; i < path->pins->size - 1; i++) {
                p  =        path->pins->data[i];
@@ -94,51 +112,63 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
 
                if (SCF_EDA_Diode_POS == p->id) {
 
-                       v  = p0->v  - p->v;
-                       jv = p0->jv - p->jv;
+                       v   = p0->v  - p->v;
+                       jv  = p0->jv - p->jv;
+
+                       pr  = p->pr  - p0->pr;
+                       jpr = p->jpr - p0->jpr;
 
-                       r  = p->pr  - p0->pr;
-                       jr = p->jpr - p0->jpr;
+                       sr  = p->sr  - p0->sr;
+                       jsr = p->jsr - p0->jsr;
 
-                       ses_ur_i(&a, &ja, v, jv, r, jr);
+                       ses_ur_i(&el->a, &el->ja, v, jv, pr, jpr);
 
-                       el->a      = a;
-                       el->ja     = ja;
+                       p->a       = el->a;
+                       p->ja      = el->ja;
                        el->aconst = 1;
 
                        if (path->childs)
-                               __ses_path_split_i(f, path, p, p1, &a, &ja);
+                               __ses_path_split_i(path, p, p1, el, &p->a, &p->ja);
 
-                       p->a  = a;
-                       p->ja = ja;
+                       __ses_path_dr(p, p1, p);
 
-                       scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, r: %lg + j%lg, p->a: %lg + j%lg\n", i, p->cid, p->id,
-                                       v, jv, p->v, p->jv, r, jr, p->a, p->ja);
+                       scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, p->a: %lg + j%lg, pr: %lg + j%lg, sr: %lg + j%lg, p->dr: %lg + j%lg\n", i, p->cid, p->id,
+                                       v, jv, p->v, p->jv, p->a, p->ja, pr, jpr, sr, jsr, p->dr, p->jdr);
 
                } else {
-                       v  = p->v    - p1->v;
-                       jv = p->jv   - p1->jv;
+                       p     = path->pins->data[i + 1];
+                       p->v  = el->v;
+                       p->jv = el->jv;
 
-                       r  = p1->pr  - p->pr;
-                       jr = p1->jpr - p->jpr;
+                       v   = p->v    - p1->v;
+                       jv  = p->jv   - p1->jv;
 
-                       double sr  = p1->sr  - p->sr;
-                       double jsr = p1->jsr - p->jsr;
+                       pr  = p1->pr  - p->pr;
+                       jpr = p1->jpr - p->jpr;
 
-                       ses_ur_i(&a, &ja, v, jv, r, jr);
+                       sr  = p1->sr  - p->sr;
+                       jsr = p1->jsr - p->jsr;
 
-                       el->a      = a;
-                       el->ja     = ja;
+                       if (p1->sr == p1->pr && p1->jsr == p1->jpr)
+                               ses_ur_i(&el->a, &el->ja, v, jv, pr, jpr);
+                       else
+                               ses_ur_i(&el->a, &el->ja, v, jv, sr, jsr);
+
+                       p->a       = el->a;
+                       p->ja      = el->ja;
                        el->aconst = 1;
 
+                       p          = path->pins->data[i];
+                       p->a       = el->a;
+                       p->ja      = el->ja;
+
                        if (path->childs)
-                               __ses_path_split_i(f, path, p0, p, &a, &ja);
+                               __ses_path_split_i(path, p0, p, el, &p->a, &p->ja);
 
-                       p->a  = a;
-                       p->ja = ja;
+                       __ses_path_dr(p0, p, p);
 
-                       scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, r: %lg + j%lg, p->a: %lg + j%lg, sr: %lg + j%lg\n", i, p->cid, p->id,
-                                       v, jv, p->v, p->jv, r, jr, p->a, p->ja, sr, jsr);
+                       scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, p->a: %lg + j%lg, pr: %lg + j%lg, sr: %lg + j%lg, p->dr: %lg + j%lg\n", i, p->cid, p->id,
+                                       v, jv, p->v, p->jv, p->a, p->ja, pr, jpr, sr, jsr, p->dr, p->jdr);
                }
        }
        printf("\n");