ses_step_va.c
authoryu.dongliang <18588496441@163.com>
Sat, 29 Jul 2023 15:33:14 +0000 (23:33 +0800)
committeryu.dongliang <18588496441@163.com>
Sat, 29 Jul 2023 15:33:14 +0000 (23:33 +0800)
ses_core.h
ses_step_va.c

index dba8c555e2b2872c0cbfdedc162c5f9214dfa3cb..62c16d1755cec8734a6838f8dab8cd441a2d2a33 100644 (file)
@@ -30,6 +30,12 @@ struct ses_path_s
        scf_vector_t*  childs;
        ses_path_t*    parent;
 
+       double         r0;
+       double         jr0;
+
+       double         r;
+       double         jr;
+
        int            type;
        int            index;
 };
index c5df06d86f7716e446ba2b4fc7a46cc861562f71..64f21fe162896649ceb12de8433859c7943b03cc 100644 (file)
@@ -1,13 +1,70 @@
 #include"ses_core.h"
 
+int __ses_path_jr(ses_path_t* path)
+{
+       if (!path)
+               return -EINVAL;
+
+       ses_path_t* child;
+       ScfEpin*    p;
+
+       int i;
+
+       path->r0  = 0;
+       path->jr0 = 0;
+
+       for (i = 0; i < path->pins->size; i++) {
+               p  =        path->pins->data[i];
+
+               path->r0  += p->r;
+               path->jr0 += p->jr;
+       }
+
+       double R  =  path->r0  * path->r0 + path->jr0 * path->jr0;
+       double r  =  path->r0  / R;
+       double jr = -path->jr0 / R;
+
+       scf_loge("path: %d, r0: %lg, jr0: %lg, r: %lg, jr: %lg\n", path->index, path->r0, path->jr0, r, jr);
+
+       if (path->childs) {
+               for (i = 0; i < path->childs->size; i++) {
+                       child     = path->childs->data[i];
+
+                       int ret = __ses_path_jr(child);
+                       if (ret < 0)
+                               return ret;
+
+                       R = child->r * child->r + child->jr * child->jr;
+
+                       double _r  =  child->r  / R;
+                       double _jr = -child->jr / R;
+
+                       r  += _r;
+                       jr += _jr;
+
+                       scf_loge("child: %d, r: %lg, jr: %lg, r0: %lg, jr0: %lg, _r: %lg, _jr: %lg\n\n",
+                                       child->index, child->r, child->jr, child->r0, child->jr0, _r, _jr);
+               }
+       }
+
+       R  =  r  * r + jr * jr;
+       r  =  r  / R;
+       jr = -jr / R;
+
+       path->r  = r;
+       path->jr = jr;
+
+       scf_loge("path: %d, r: %lg, jr: %lg, r0: %lg, jr0: %lg\n",
+                       path->index, path->r, path->jr, path->r0, path->jr0);
+       return 0;
+}
+
 static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
 {
+       ses_path_t*      path;
        ScfEcomponent*   c;
        ScfEcomponent*   B;
        ScfEline*        el;
-       ScfEline*        el2;
-       ScfEline*        elp;
-       ScfEline*        eln;
        ScfEpin*         p;
 
        size_t i;
@@ -16,6 +73,18 @@ static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ct
 
        B = f->components[0];
 
+       for (i = 0; i < ctx->paths->size; i++) {
+               path      = ctx->paths->data[i];
+
+               scf_logi("i: %ld, path->type: %d\n", i, path->type);
+
+               int ret = __ses_path_jr(path);
+               if (ret < 0)
+                       return ret;
+
+               printf("\n");
+       }
+
        return 0;
 }