From dae9e541a4a365b4cb82b6f5a89d73139139742b Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sun, 24 Sep 2023 22:01:10 +0800 Subject: [PATCH] __ses_bridge_i() --- ses_step_va_balance.c | 64 +++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/ses_step_va_balance.c b/ses_step_va_balance.c index 8e2a399..c3df7d6 100644 --- a/ses_step_va_balance.c +++ b/ses_step_va_balance.c @@ -43,6 +43,29 @@ int ses_paths_find_flow(ses_flow_t* flow, scf_vector_t* paths, ScfEpin* vip, ses return 0; } +static void inline __ses_bridge_i(double* i0, double* i1, double* i2, double* i3, double* i4, + double* v0, double* v1, double* v4, double V, + double R0, double R1, double R2, double R3, double R4, + double vd0, double vd1, double vd2, double vd3, double vd4) +{ + double N0 = R3 * (R0 + R1) + R4 * (R1 + R3); + double N2 = (R1 + R3) * (R2 + R4) + R3 * (R1 - R2); + double RV02 = R1 * (vd2 + vd4 - vd3) + R3 * (vd1 + vd4 - vd0); +/* + N0 i0 - N2 i2 = RV02 + R0 i0 + R2 i2 = V - vd0 - vd1 + */ + *i2 = (N0 * (V - vd0 - vd1) - R0 * RV02) / (N0 * R2 + R0 * N2); + *i0 = (N2 * *i2 + RV02) / N0; + *i4 = *i2 - *i0; + + *i1 = (*i0 * R0 + vd0 - *i4 * R4 - vd4 - vd1) / R1; + *i3 = *i1 - *i4; + + *v0 = *i2 * R2 + vd2; + *v1 = *i3 * R3 + vd3; + *v4 = *i4 * R4 + vd4; +} static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t* flow0, ses_flow_t* flow1) { @@ -63,11 +86,11 @@ static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t ses_path_t* path0 = flow0->paths->data[flow0->paths->size - 1]; ses_path_t* path1 = flow1->paths->data[flow1->paths->size - 1]; - ScfEpin* r0p0 = path0->pins->data[0]; - ScfEpin* r0p1 = path0->pins->data[path0->pins->size - 1]; + ScfEpin* p0p0 = path0->pins->data[0]; + ScfEpin* p0p1 = path0->pins->data[path0->pins->size - 1]; - ScfEpin* r1p0 = path1->pins->data[0]; - ScfEpin* r1p1 = path1->pins->data[path1->pins->size - 1]; + ScfEpin* p1p0 = path1->pins->data[0]; + ScfEpin* p1p1 = path1->pins->data[path1->pins->size - 1]; int i; int j; @@ -85,24 +108,31 @@ static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t if (p0->v > p1->v) { - double v = r0p0->v - r1p1->v; - double jv = r0p0->jv - r1p1->jv; - - double r = flow0->pr + bridge->r + flow1->nr; - double jr = flow0->jpr + bridge->jr + flow1->jnr; + double v = p0p0->v - p1p1->v; - double a; - double ja; + double a0; + double a1; + double a2; + double a3; + double a4; + double v0; + double v1; + double v4; - double dv; - double jdv; + __ses_bridge_i(&a0, &a1, &a2, &a3, &a4, &v0, &v1, &v4, v, + flow1->pr, flow0->pr, flow1->nr, flow0->nr, 0, + 0, 0, 0, 0, + bridge->n_diodes * SCF_EDA_V_Diode_ON); - ses_ur_i(&a, &ja, v, jv, r, jr); +// ses_flow_v_pos(flow0, a, ja); +// ses_flow_v_neg(flow1, a, ja); - ses_flow_v_pos(flow0, a, ja); - ses_flow_v_neg(flow1, a, ja); + scf_loge("r0: %lg, r1: %lg, r2: %lg, r3: %lg, r4: %lg\n", + flow1->pr, flow0->pr, + flow1->nr, flow0->nr, bridge->r); - scf_loge("r->pr: %lg + j%lg, v: %lg + j%lg, a: %lg + j%lg, dv: %lg + j%lg\n", r, jr, v, jv, a, ja, dv, jdv); + scf_loge("v: %lg, a0: %lg, a1: %lg, a2: %lg, a3: %lg, a4: %lg\n", v, a0, a1, a2, a3, a4); + scf_loge("v0: %lg, v1: %lg, v4: %lg, v1 - v0: %lg\n", v0, v1, v4, v1 - v0); } else { -- 2.25.1