CFILES += ses_step_topo.c
CFILES += ses_step_jr.c
+CFILES += ses_step_va_diode.c
+CFILES += ses_step_va_transistor.c
CFILES += ses_step_va.c
CFILES += ses_step_va_balance.c
CFILES += ses_step_output.c
--- /dev/null
+#include"ses_core.h"
+
+static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
+{
+ if (!path)
+ return -EINVAL;
+
+ if (path->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ ses_path_t* child;
+ ScfEcomponent* c;
+ ScfEline* el;
+ ScfEpin* p;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* p2;
+ ScfEpin* cp0;
+ ScfEpin* cp1;
+
+ int i;
+ int j;
+ int k;
+
+ p0 = path->pins->data[0];
+ p1 = path->pins->data[path->pins->size - 1];
+
+ el = f->elines[p0->lid];
+ p0->v = el->v;
+ p0->jv = el->jv;
+
+ el = f->elines[p1->lid];
+ 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;
+
+ ses_ur_i(&a, &ja, v, jv, path->r, path->jr);
+
+ 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);
+
+ double r = 0;
+ double jr = 0;
+ double dv = 0;
+ double jdv = 0;
+
+ for (i = 0; i < path->pins->size; i++) {
+ p = path->pins->data[i];
+
+ 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];
+
+ int ret = __ses_path_va_diode(f, child);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ }
+ printf("\n");
+
+ return 0;
+}
+
+static int _va_diode_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+{
+ ses_path_t* path;
+ ScfEcomponent* B;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* Bp;
+ ScfEpin* Bn;
+
+ size_t i;
+ size_t j;
+ size_t k;
+
+ B = f->components[0];
+ Bp = B->pins[SCF_EDA_Battery_POS];
+ Bn = B->pins[SCF_EDA_Battery_NEG];
+
+ for (i = 0; i < ctx->paths->size; i++) {
+ path = ctx->paths->data[i];
+
+ scf_logi("i: %ld, path->type: %d\n", i, path->type);
+
+ if (path->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ p0 = path->pins->data[0];
+ p1 = path->pins->data[path->pins->size - 1];
+
+ if (p0->lid != Bp->lid || p1->lid != Bn->lid)
+ continue;
+
+ int ret = __ses_path_va_diode(f, path);
+ if (ret < 0)
+ return ret;
+
+ printf("\n");
+ }
+
+ return 0;
+}
+
+ses_step_t ses_step_va_diode =
+{
+ .name = "va_diode",
+
+ .handler = _va_diode_handler,
+};
--- /dev/null
+#include"ses_core.h"
+
+static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
+{
+ if (!path)
+ return -EINVAL;
+
+ if (path->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ ses_path_t* child;
+ ScfEcomponent* c;
+ ScfEline* el;
+ ScfEpin* p;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* p2;
+ ScfEpin* cp0;
+ ScfEpin* cp1;
+
+ int i;
+ int j;
+ int k;
+
+ p0 = path->pins->data[0];
+ p1 = path->pins->data[path->pins->size - 1];
+
+ el = f->elines[p0->lid];
+ p0->v = el->v;
+ p0->jv = el->jv;
+
+ el = f->elines[p1->lid];
+ 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;
+
+ ses_ur_i(&a, &ja, v, jv, path->r, path->jr);
+
+ 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);
+
+ double r = 0;
+ double jr = 0;
+ double dv = 0;
+ double jdv = 0;
+
+ for (i = 0; i < path->pins->size; i++) {
+ p = path->pins->data[i];
+
+ 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];
+
+ int ret = __ses_path_va_transistor(f, child);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ }
+ printf("\n");
+
+ return 0;
+}
+
+static int _va_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+{
+ ses_path_t* path;
+ ScfEcomponent* B;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* Bp;
+ ScfEpin* Bn;
+
+ size_t i;
+ size_t j;
+ size_t k;
+
+ B = f->components[0];
+ Bp = B->pins[SCF_EDA_Battery_POS];
+ Bn = B->pins[SCF_EDA_Battery_NEG];
+
+ for (i = 0; i < ctx->paths->size; i++) {
+ path = ctx->paths->data[i];
+
+ scf_logi("i: %ld, path->type: %d\n", i, path->type);
+
+ if (path->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ p0 = path->pins->data[0];
+ p1 = path->pins->data[path->pins->size - 1];
+
+ if (p0->lid != Bp->lid || p1->lid != Bn->lid)
+ continue;
+
+ int ret = __ses_path_va_transistor(f, path);
+ if (ret < 0)
+ return ret;
+
+ printf("\n");
+ }
+
+ return 0;
+}
+
+ses_step_t ses_step_va_transistor =
+{
+ .name = "va_transistor",
+
+ .handler = _va_transistor_handler,
+};
extern ses_step_t ses_step_simplify;
extern ses_step_t ses_step_topo;
+
extern ses_step_t ses_step_jr;
+extern ses_step_t ses_step_va_diode;
+extern ses_step_t ses_step_va_transistor;
extern ses_step_t ses_step_va;
extern ses_step_t ses_step_va_balance;
&ses_step_topo,
&ses_step_jr,
+ &ses_step_va_diode,
+ &ses_step_va_transistor,
&ses_step_va,
&ses_step_va_balance,