__ses_flow_v_neg()
authoryu.dongliang <18588496441@163.com>
Fri, 17 Nov 2023 04:42:46 +0000 (12:42 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 17 Nov 2023 04:42:46 +0000 (12:42 +0800)
ses_step_va_bridge.c

index b40f6d69ae04e3f06f6200cbfc50d23c0c95348e..123a254ab8ab83b60bb233172e73a2a06a913f63 100644 (file)
@@ -93,6 +93,7 @@ int __ses_flow_v_neg(ScfEfunction* f, ses_flow_t* flow, double dv_vip, double dj
        if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip)
                return -EINVAL;
 
+       ScfEcomponent* c;
        ScfEcomponent* B    = f->components[0];
        ScfEpin*       Bp   = B->pins[SCF_EDA_Battery_POS];
        ScfEpin*       Bn   = B->pins[SCF_EDA_Battery_NEG];
@@ -103,8 +104,8 @@ int __ses_flow_v_neg(ScfEfunction* f, ses_flow_t* flow, double dv_vip, double dj
        ScfEpin*       p;
        ScfEline*      el;
 
-       double tr  = flow->neg_r;
-       double jtr = flow->neg_jr;
+       double v  = dv_vip;
+       double jv = djv_vip;
 
        double da;
        double dja;
@@ -112,16 +113,13 @@ int __ses_flow_v_neg(ScfEfunction* f, ses_flow_t* flow, double dv_vip, double dj
        int i;
        int j;
 
-       ses_ur_i(&da, &dja, dv_vip, djv_vip, tr, jtr);
+       ses_ur_i(&da, &dja, dv_vip, djv_vip, flow->neg_r, flow->neg_jr);
 
        for (i   = 0; i < flow->paths->size; i++) {
                path =        flow->paths->data[i];
 
-               double v;
-               double jv;
-
-               double r;
-               double jr;
+               double r  = 0;
+               double jr = 0;
 
                int j0 = -1;
                for (j = 0; j < path->pins->size; j++) {
@@ -134,15 +132,16 @@ int __ses_flow_v_neg(ScfEfunction* f, ses_flow_t* flow, double dv_vip, double dj
                                        continue;
                        }
 
-                       __ses_path_pr(f, path, j0, j, NULL, &r, &jr);
+                       r  += p->r  + p->dr;
+                       jr += p->jr + p->jdr;
 
-                       r  = tr  - r;
-                       jr = jtr - jr;
-
-                       if (p->sr != p->pr)
-                               j0 = j;
+                       if (j & 0x1) {
+                               c   = f->components[p->cid];
+                               r  += c->r;
+                               jr += c->jr;
 
-                       ses_ir_u(&v, &jv, da, dja, r, jr);
+                               ses_ir_u(&v, &jv, da, dja, r, jr);
+                       }
 
                        if (p->lid != Bn->lid) {
                                p->v   += v;
@@ -153,33 +152,15 @@ int __ses_flow_v_neg(ScfEfunction* f, ses_flow_t* flow, double dv_vip, double dj
                                el->jv  = p->jv;
                        }
 
-                       scf_logw("c%ldp%ld->v: %lg, r: %lg, l%ld->v: %lg\n", p->cid, p->id, p->v, r, el->id, el->v);
-               }
-
-               assert(p0);
-
-               vip = path->pins->data[j - 1];
-
-               if (j - 1 != j0) {
-
-                       __ses_path_sr(f, path, j0, j, NULL, &r, &jr);
-
-                       tr  -= r;
-                       jtr -= jr;
+                       scf_logw("c%ldp%ld->v: %lg, r: %lg, v: %lg, l%ld->v: %lg\n", p->cid, p->id, p->v, r, v, el->id, el->v);
 
-                       ses_ir_u(&v, &jv, da, dja, r, jr);
-
-                       if (vip->lid != Bn->lid) {
-                               vip->v   += v;
-                               vip->jv  += jv;
-
-                               el        = f->elines[vip->lid];
-                               el->v     = vip->v;
-                               el->jv    = vip->jv;
+                       if (j & 0x1) {
+                               r  = 0;
+                               jr = 0;
                        }
-
-                       scf_logw("c%ldp%ld->v: %lg, r: %lg, l%ld->v: %lg\n", vip->cid, vip->id, vip->v, tr, el->id, el->v);
                }
+
+               vip = path->pins->data[j - 1];
        }
 
        return 0;
@@ -289,7 +270,7 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* bridge, int* change
                printf("\n");
 
                k++;
-       } while (da > 1e-5);
+       } while (da > 1e-4);
 
        v  = p0->v  - p1->v;
        jv = p0->jv - p1->jv;