From dc610b0c68e2bb6cf01231cdd7dd197002376b5f Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 6 Sep 2023 14:03:07 +0800 Subject: [PATCH] tmp --- ses_core.h | 11 ++++++ ses_step_va_diode.c | 93 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 84 insertions(+), 20 deletions(-) diff --git a/ses_core.h b/ses_core.h index 92eebf9..6a2e12d 100644 --- a/ses_core.h +++ b/ses_core.h @@ -116,4 +116,15 @@ static inline void ses_ir_u(double* v, double* jv, double a, double ja, double r *jv = ja * r + a * jr; } +static inline void ses_split_i(double* a, double* ja, double ta, double jta, double r, double jr, double pr, double jpr) +{ + double R = r * r + jr * jr; + + double t = ta * pr - jta * jpr; + double jt = jta * pr + ta * jpr; + + *a = ( t * r + jt * jr) / R; + *ja = (jt * r - t * jr) / R; +} + #endif diff --git a/ses_step_va_diode.c b/ses_step_va_diode.c index 4c163eb..7986b07 100644 --- a/ses_step_va_diode.c +++ b/ses_step_va_diode.c @@ -17,6 +17,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) ScfEpin* p0; ScfEpin* p1; ScfEpin* p2; + ScfEpin* cp; ScfEpin* cp0; ScfEpin* cp1; @@ -35,35 +36,87 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) p1->v = el->v; p1->jv = el->jv; - double v = p0->v - p1->v; - double jv = p0->jv - p1->jv; - double a = 0; - double ja = 0; + double v; + double jv; + double a; + double ja; + double r; + double jr; - ses_ur_i(&a, &ja, v, jv, path->r, path->jr); + for (i = 0; i < path->pins->size; i++) { + p = path->pins->data[i]; - scf_loge("path: %d, v: %lg + j%lg, r: %lg + j%lg, a: %lg + j%lg\n", path->index, v, jv, path->r, path->jr, a, ja); + el = f->elines [p->lid]; + c = f->components[p->cid]; - double r = 0; - double jr = 0; - double dv = 0; - double jdv = 0; + if (!el->vconst) + continue; - for (i = 0; i < path->pins->size; i++) { - p = path->pins->data[i]; + if (SCF_EDA_Diode != c->type) + continue; + + p->v = el->v; + p->jv = el->jv; + + if (SCF_EDA_Diode_POS == p->id) { + + v = p0->v - p->v; + jv = p0->jv - p->jv; + + r = p1->pr - p->pr; + jr = p1->jpr - p->jpr; + + ses_ur_i(&a, &ja, v, jv, p->pr, p->jpr); + + el->a = a; + el->ja = ja; + el->aconst = 1; - if (path->childs) { - for (j = 0; j < path->childs->size; j++) { - child = path->childs->data[j]; + if (path->childs) { + for (j = 0; j < path->childs->size; j++) { + child = path->childs->data[j]; - cp0 = child->pins->data[0]; - cp1 = child->pins->data[child->pins->size - 1]; + cp0 = child->pins->data[0]; + cp1 = child->pins->data[child->pins->size - 1]; - int ret = __ses_path_va_diode(f, child); - if (ret < 0) - return ret; + if (cp0->lid != p->lid || cp1->lid != p1->lid) + continue; + + ses_split_i(&child->a, &child->ja, el->a, el->ja, child->r, child->jr, r, jr); + + double cr; + double jcr; + + v = p->v - p1->v; + jv = p->jv - p1->jv; + + ses_ui_r(&cr, &jcr, v, jv, child->a, child->ja); + + for (k = 0; k < child->pins->size; k++) { + cp = child->pins->data[k]; + + c = f->components[cp->cid]; + + if (SCF_EDA_Diode == c->type) { + cp->dr = cr - child->r; + cp->jdr = jcr - child->jr; + break; + } + } + } } + + } else { + v = p->v - p1->v; + jv = p->jv - p1->jv; + + ses_ur_i(&a, &ja, v, jv, p1->pr - p->pr, p1->jpr - p->jpr); + + el->a = a; + el->ja = ja; + el->aconst = 1; } + } printf("\n"); -- 2.25.1