int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count);
-static void vertical(int* px, int* py, int dx, int dy, int d)
+static inline void vertical(int* px, int* py, int dx, int dy, int d)
{
/*
[cos90, -sin90] [0 -1] x
*py = dx * d / R;
}
-static void forward(int* px, int* py, int dx, int dy, int d)
+static inline void forward(int* px, int* py, int dx, int dy, int d)
{
double R = sqrt(dx * dx + dy * dy);
*py = dy * d / R;
}
+static inline void ses_ur_i(double* a, double* ja, double v, double jv, double r, double jr)
+{
+ double R = r * r + jr * jr;
+
+ *a = ( v * r + jv * jr) / R;
+ *ja = (jv * r - v * jr) / R;
+}
+
+static inline void ses_ui_r(double* r, double* jr, double v, double jv, double a, double ja)
+{
+ double R = a * a + ja * ja;
+
+ *r = ( v * a + jv * ja) / R;
+ *jr = (jv * a - v * ja) / R;
+}
+
+static inline void ses_ir_u(double* v, double* jv, double a, double ja, double r, double jr)
+{
+ *v = a * r - ja * jr;
+ *jv = ja * r + a * jr;
+}
+
#endif
--- /dev/null
+#include"ses_core.h"
+
+int _ses_path_cmp(const void* v0, const void* v1);
+
+static int __ses_path_jr(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;
+ ScfEpin* p;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* cp0;
+ ScfEpin* cp1;
+
+ double R;
+ double r;
+ double jr;
+
+ int i;
+ int j;
+
+ r = 0;
+ jr = 0;
+
+ for (i = 0; i < path->pins->size; i++) {
+ p = path->pins->data[i];
+
+ r += p->r + p->dr;
+ jr += p->jr + p->jdr;
+
+ if (i & 0x1) {
+ c = f->components[p->cid];
+ r += c->r;
+ jr += c->jr;
+ }
+
+ p->sr = r;
+ p->jsr = jr;
+
+ p->pr = r;
+ p->jpr = jr;
+
+ scf_loge("i: %d, c%ldp%ld, p->tr: %lg, p->jtr: %lg\n", i, p->cid, p->id, p->sr, p->jsr);
+ }
+ printf("\n");
+
+ if (path->childs) {
+
+ scf_vector_qsort(path->childs, _ses_path_cmp);
+
+ for (i = path->childs->size - 1; i >= 0; i--) {
+ child = path->childs->data[i];
+
+ int ret = __ses_path_jr(f, child);
+ if (ret < 0)
+ return ret;
+
+ cp0 = child->pins->data[0];
+ cp1 = child->pins->data[child->pins->size - 1];
+ p0 = NULL;
+ p1 = NULL;
+
+ for (j = 0; j < path->pins->size; j++) {
+ p = path->pins->data[j];
+
+ if (p->lid == cp0->lid) {
+ p0 = p;
+ break;
+ }
+ }
+
+ if (!p0)
+ return -EINVAL;
+
+ for ( ; j < path->pins->size; j++) {
+ p = path->pins->data[j];
+
+ if (p->lid == cp1->lid) {
+ p1 = p;
+ break;
+ }
+ }
+
+ if (!p1)
+ return -EINVAL;
+
+ R = child->r * child->r + child->jr * child->jr;
+
+ double _r = child->r / R;
+ double _jr = -child->jr / R;
+
+ r = p1->pr - p0->pr;
+ jr = p1->jpr - p0->jpr;
+
+ R = r * r + jr * jr;
+ r = r / R;
+ jr = -jr / R;
+
+ r += _r;
+ jr += _jr;
+
+ R = r * r + jr * jr;
+ r = r / R;
+ jr = -jr / R;
+
+ double dr = p1->pr - (p0->pr + r);
+ double jdr = p1->jpr - (p0->jpr + jr);
+
+ for ( ; j < path->pins->size; j++) {
+ p = path->pins->data[j];
+
+ p->pr -= dr;
+ p->jpr -= jdr;
+
+ scf_logw("j: %d, c%ldp%ld, p->pr: %lg + j%lg\n", j, p->cid, p->id, p->pr, p->jpr);
+ }
+
+ scf_loge("child: %d, r: %lg, jr: %lg, r0: %lg, jr0: %lg, _r: %lg, _jr: %lg, dr: %lg, jdr: %lg\n\n",
+ child->index, child->r, child->jr, child->r0, child->jr0, _r, _jr, dr, jdr);
+ }
+ }
+
+ p = path->pins->data[path->pins->size - 1];
+
+ path->r = p->pr;
+ path->jr = p->jpr;
+
+ 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 _jr_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;
+
+ 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(f, path);
+ if (ret < 0)
+ return ret;
+
+ printf("\n");
+ }
+
+ return 0;
+}
+
+ses_step_t ses_step_jr =
+{
+ .name = "jr",
+
+ .handler = _jr_handler,
+};
int _ses_path_cmp(const void* v0, const void* v1);
-static inline void __ses_ur_i(double* a, double* ja, double v, double jv, double r, double jr)
-{
- double R = r * r + jr * jr;
-
- *a = ( v * r + jv * jr) / R;
- *ja = (jv * r - v * jr) / R;
-}
-
-static inline void __ses_ui_r(double* r, double* jr, double v, double jv, double a, double ja)
-{
- double R = a * a + ja * ja;
-
- *r = ( v * a + jv * ja) / R;
- *jr = (jv * a - v * ja) / R;
-}
-
-static inline void __ses_ir_u(double* v, double* jv, double a, double ja, double r, double jr)
-{
- *v = a * r - ja * jr;
- *jv = ja * r + a * jr;
-}
-
-static int __ses_path_jr(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;
- ScfEpin* p;
- ScfEpin* p0;
- ScfEpin* p1;
- ScfEpin* cp0;
- ScfEpin* cp1;
-
- double R;
- double r;
- double jr;
-
- int i;
- int j;
-
- r = 0;
- jr = 0;
-
- for (i = 0; i < path->pins->size; i++) {
- p = path->pins->data[i];
-
- r += p->r;
- jr += p->jr;
-
- if (i & 0x1) {
- c = f->components[p->cid];
- r += c->r;
- jr += c->jr;
- }
-
- p->sr = r;
- p->jsr = jr;
-
- p->pr = r;
- p->jpr = jr;
-
- scf_loge("i: %d, c%ldp%ld, p->tr: %lg, p->jtr: %lg\n", i, p->cid, p->id, p->sr, p->jsr);
- }
- printf("\n");
-
- if (path->childs) {
-
- scf_vector_qsort(path->childs, _ses_path_cmp);
-
- for (i = path->childs->size - 1; i >= 0; i--) {
- child = path->childs->data[i];
-
- int ret = __ses_path_jr(f, child);
- if (ret < 0)
- return ret;
-
- cp0 = child->pins->data[0];
- cp1 = child->pins->data[child->pins->size - 1];
- p0 = NULL;
- p1 = NULL;
-
- for (j = 0; j < path->pins->size; j++) {
- p = path->pins->data[j];
-
- if (p->lid == cp0->lid) {
- p0 = p;
- break;
- }
- }
-
- if (!p0)
- return -EINVAL;
-
- for ( ; j < path->pins->size; j++) {
- p = path->pins->data[j];
-
- if (p->lid == cp1->lid) {
- p1 = p;
- break;
- }
- }
-
- if (!p1)
- return -EINVAL;
-
- R = child->r * child->r + child->jr * child->jr;
-
- double _r = child->r / R;
- double _jr = -child->jr / R;
-
- r = p1->pr - p0->pr;
- jr = p1->jpr - p0->jpr;
-
- R = r * r + jr * jr;
- r = r / R;
- jr = -jr / R;
-
- r += _r;
- jr += _jr;
-
- R = r * r + jr * jr;
- r = r / R;
- jr = -jr / R;
-
- double dr = p1->pr - (p0->pr + r);
- double jdr = p1->jpr - (p0->jpr + jr);
-
- for ( ; j < path->pins->size; j++) {
- p = path->pins->data[j];
-
- p->pr -= dr;
- p->jpr -= jdr;
-
- scf_logw("j: %d, c%ldp%ld, p->pr: %lg + j%lg\n", j, p->cid, p->id, p->pr, p->jpr);
- }
-
- scf_loge("child: %d, r: %lg, jr: %lg, r0: %lg, jr0: %lg, _r: %lg, _jr: %lg, dr: %lg, jdr: %lg\n\n",
- child->index, child->r, child->jr, child->r0, child->jr0, _r, _jr, dr, jdr);
- }
- }
-
- p = path->pins->data[path->pins->size - 1];
-
- path->r = p->pr;
- path->jr = p->jpr;
-
- 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 __ses_path_va(ScfEfunction* f, ses_path_t* path)
{
if (!path)
double a = 0;
double ja = 0;
- __ses_ur_i(&a, &ja, v, jv, path->r, path->jr);
+ 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 _a = 0;
double _ja = 0;
- __ses_ir_u(&_v, &_jv, a, ja, _r, _jr);
- __ses_ur_i(&_a, &_ja, _v, _jv, child->r, child->jr);
+ ses_ir_u(&_v, &_jv, a, ja, _r, _jr);
+ ses_ur_i(&_a, &_ja, _v, _jv, child->r, child->jr);
a -= _a;
ja -= _ja;
}
}
- __ses_ir_u(&v, &jv, a, ja, p->sr, p->jsr);
+ ses_ir_u(&v, &jv, a, ja, p->sr, p->jsr);
p->v = p0->v - v;
p->jv = p0->jv - jv;
dv -= p->v;
jdv -= p->jv;
- __ses_ur_i(&p->a, &p->ja, dv, jdv, r, jr);
+ ses_ur_i(&p->a, &p->ja, dv, jdv, r, jr);
scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, dv: %lg + j%lg, r: %lg + j%lg, a: %lg + j%lg\n\n", i, p->cid, p->id,
v, jv, p->v, p->jv, dv, jdv, r, jr, p->a, p->ja);
size_t j;
size_t k;
- 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(f, path);
- if (ret < 0)
- return ret;
-
- printf("\n");
- }
-
B = f->components[0];
Bp = B->pins[SCF_EDA_Battery_POS];
Bn = B->pins[SCF_EDA_Battery_NEG];
-#if 1
+
printf("\n*******************\n");
for (i = 0; i < ctx->paths->size; i++) {
printf("\n");
}
-#endif
+
return 0;
}
.name = "va",
.handler = _va_handler,
-
};