*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
ScfEpin* p0;
ScfEpin* p1;
ScfEpin* p2;
+ ScfEpin* cp;
ScfEpin* cp0;
ScfEpin* cp1;
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");