#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;
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];
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;
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];
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");