From d5973e813dde1649777bff12aece63f06bc55012 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 27 Sep 2023 22:36:40 +0800 Subject: [PATCH] ses_step_va_diode.c --- ses_step_va_diode.c | 142 ++++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 63 deletions(-) diff --git a/ses_step_va_diode.c b/ses_step_va_diode.c index b951489..d859acb 100644 --- a/ses_step_va_diode.c +++ b/ses_step_va_diode.c @@ -80,7 +80,8 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) ScfEpin* p; ScfEpin* p0; ScfEpin* p1; - ScfEpin* p2; + ScfEpin* pi; + ScfEpin* pj; int i; int j; @@ -97,98 +98,113 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) p1->v = el->v; p1->jv = el->jv; - double v; - double jv; + for (i = 0; i < path->pins->size; i++) { + pi = path->pins->data[i]; - double pr; - double jpr; - double sr; - double jsr; + el = f->elines [pi->lid]; + c = f->components[pi->cid]; - for (i = 1; i < path->pins->size - 1; i++) { - p = path->pins->data[i]; + if (!el->vconst) + break; + + pi->v = el->v; + pi->jv = el->jv; - el = f->elines [p->lid]; - c = f->components[p->cid]; + if (SCF_EDA_Diode != c->type) + break; + } + + for (j = path->pins->size - 1; j >= i; j--) { + pj = path->pins->data[j]; + + el = f->elines [pj->lid]; + c = f->components[pj->cid]; if (!el->vconst) - continue; + break; + + pj->v = el->v; + pj->jv = el->jv; if (SCF_EDA_Diode != c->type) - continue; + break; + } - p->v = el->v; - p->jv = el->jv; + if (j <= i) { + scf_loge("all components are Diode\n"); + return -1; + } - if (SCF_EDA_Diode_POS == p->id) { + if (j < path->pins->size - 1) + pj = path->pins->data[j + 1]; - v = p0->v - p->v; - jv = p0->jv - p->jv; + double v = pi->v - pj->v; + double jv = pi->jv - pj->jv; - pr = p->pr - p0->pr; - jpr = p->jpr - p0->jpr; + double pr = pj->pr - pi->pr; + double jpr = pj->jpr - pi->jpr; - sr = p->sr - p0->sr; - jsr = p->jsr - p0->jsr; + double sr = pj->sr - pi->sr; + double jsr = pj->jsr - pi->jsr; - ses_ur_i(&el->a, &el->ja, v, jv, pr, jpr); + double a; + double ja; - p->a = el->a; - p->ja = el->ja; - el->aconst = 1; + if (j == path->pins->size - 1 + && p1->sr == p1->pr + && p1->jsr == p1->jpr) + ses_ur_i(&a, &ja, v, jv, pr, jpr); + else + ses_ur_i(&a, &ja, v, jv, sr, jsr); - if (path->childs) - __ses_path_split_i(path, p, p1, el->a, el->ja, &p->a, &p->ja); + if (SCF_EDA_Diode_POS == pj->id) { - p2 = c->pins[SCF_EDA_Diode_NEG]; - p2->a = p->a; - p2->ja = p->ja; + el = f->elines[pj->lid]; + el->a = a; + el->ja = ja; + el->aconst = 1; - __ses_path_dr(p, p1, p2); + pj->a = a; + pj->ja = ja; - scf_loge("i: %d, c%ldp%ld--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, p2->dr: %lg + j%lg\n\n", - i, p->cid, p->id, p1->cid, p1->id, v, jv, p->v, p->jv, p->a, p->ja, pr, jpr, sr, jsr, p2->dr, p2->jdr); + if (path->childs) + __ses_path_split_i(path, pj, p1, a, ja, &pj->a, &pj->ja); - } else { - p = path->pins->data[i + 1]; - p->v = el->v; - p->jv = el->jv; + c = f->components[pj->cid]; + p = c->pins[SCF_EDA_Diode_NEG]; + p->a = pj->a; + p->ja = pj->ja; - v = p->v - p1->v; - jv = p->jv - p1->jv; + __ses_path_dr(pj, p1, p); - pr = p1->pr - p->pr; - jpr = p1->jpr - p->jpr; + scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, pj->v: %lg, pj->a: %lg, pr: %lg, sr: %lg, p->dr: %lg\n\n", + j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr, p->dr); + } - sr = p1->sr - p->sr; - jsr = p1->jsr - p->jsr; + if (i > 0) + pi = path->pins->data[i - 1]; - 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); + if (SCF_EDA_Diode_NEG == pi->id) { - p->a = el->a; - p->ja = el->ja; - el->aconst = 1; + el = f->elines[pi->lid]; + el->a = a; + el->ja = ja; + el->aconst = 1; - p = path->pins->data[i]; - p->a = el->a; - p->ja = el->ja; + pi->a = a; + pi->ja = ja; - if (path->childs) - __ses_path_split_i(path, p0, p, el->a, el->ja, &p->a, &p->ja); + if (path->childs) + __ses_path_split_i(path, p0, pi, a, ja, &pi->a, &pi->ja); - __ses_path_dr(p0, p, p); + __ses_path_dr(p0, pi, pi); - p0->a = p->a; - p0->ja = p->ja; + p0->a = pi->a; + p0->ja = pi->ja; - scf_loge("i: %d, c%ldp%ld--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\n", - i, p0->cid, p0->id, p->cid, p->id, v, jv, p->v, p->jv, p->a, p->ja, pr, jpr, sr, jsr, p->dr, p->jdr); - } + scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pi->v: %lg, pi->a: %lg, pr: %lg, sr: %lg, p->dr: %lg\n\n", + i, p0->cid, p0->id, pi->cid, pi->id, v, pi->v, pi->a, pr, sr, pi->dr); } - printf("\n"); return 0; } -- 2.25.1