From 010485b1980652e698288a424f44d534995942c6 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Sat, 13 Jul 2024 14:18:44 +0300 Subject: [PATCH 1/2] Add TRAN model for MLIN device --- src/components/microstrip/msline.cpp | 40 ++++++++++++++++++++++++++-- src/components/microstrip/msline.h | 2 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/components/microstrip/msline.cpp b/src/components/microstrip/msline.cpp index 98ade34b..3fa2c505 100644 --- a/src/components/microstrip/msline.cpp +++ b/src/components/microstrip/msline.cpp @@ -73,11 +73,11 @@ void msline::calcPropagation (nr_double_t frequency) { // analyse dispersion of Zl and Er (use WEff here?) analyseDispersion (W, h, er, ZlEff, ErEff, frequency, DModel, - ZlEffFreq, ErEffFreq); + ZlEffFreq, ErEffFreq); // analyse losses of line analyseLoss (W, t, er, rho, D, tand, ZlEff, ZlEff, ErEff, - frequency, "Hammerstad", ac, ad); + frequency, "Hammerstad", ac, ad); // calculate propagation constants and reference impedance zl = ZlEffFreq; @@ -485,6 +485,42 @@ void msline::calcNoiseAC (nr_double_t) { setMatrixN (4 * celsius2kelvin (T) / T0 * real (getMatrixY ())); } + +void msline::initTR (void) { + nr_double_t l = getPropertyDouble ("L"); + + calcPropagation(0.0); + + deleteHistory (); + if (l > 0.0) { + setVoltageSources (2); + allocMatrixMNA (); + setHistory (true); + initHistory (l * qucs::sqrt(ereff) / C0); + setB (NODE_1, VSRC_1, +1); setB (NODE_2, VSRC_2, +1); + setC (VSRC_1, NODE_1, +1); setC (VSRC_2, NODE_2, +1); + setD (VSRC_1, VSRC_1, -zl); setD (VSRC_2, VSRC_2, -zl); + } else { + setVoltageSources (1); + allocMatrixMNA (); + voltageSource (VSRC_1, NODE_1, NODE_2); + } +} + +void msline::calcTR (nr_double_t t) { + nr_double_t l = getPropertyDouble ("L"); + nr_double_t T = l * qucs::sqrt(ereff) / C0; + nr_double_t a = alpha; + if (T > 0.0) { + T = t - T; + a = std::exp (-a / 2 * l); + setE (VSRC_1, a * (getV (NODE_2, T) + zl * getJ (VSRC_2, T))); + setE (VSRC_2, a * (getV (NODE_1, T) + zl * getJ (VSRC_1, T))); + } +} + + + // properties PROP_REQ [] = { { "W", PROP_REAL, { 1e-3, PROP_NO_STR }, PROP_POS_RANGE }, diff --git a/src/components/microstrip/msline.h b/src/components/microstrip/msline.h index a204d947..d9aab32d 100644 --- a/src/components/microstrip/msline.h +++ b/src/components/microstrip/msline.h @@ -37,6 +37,8 @@ class msline : public qucs::circuit void calcAC (nr_double_t); void calcNoiseAC (nr_double_t); void saveCharacteristics (nr_double_t); + void initTR(); + void calcTR(nr_double_t); static void analyseQuasiStatic (nr_double_t, nr_double_t, nr_double_t, nr_double_t, const char * const, From f16964355a92da7eefb9939f6f1e6d233262ea0c Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Sat, 13 Jul 2024 14:36:44 +0300 Subject: [PATCH 2/2] Add TRAN model for COAX device --- src/components/coaxline.cpp | 39 +++++++++++++++++++++++++++++++++++++ src/components/coaxline.h | 2 ++ 2 files changed, 41 insertions(+) diff --git a/src/components/coaxline.cpp b/src/components/coaxline.cpp index 6304e914..e04023e2 100644 --- a/src/components/coaxline.cpp +++ b/src/components/coaxline.cpp @@ -167,6 +167,45 @@ void coaxline::calcNoiseAC (nr_double_t) { setMatrixN (4 * celsius2kelvin (T) / T0 * real (getMatrixY ())); } +void coaxline::initTR (void) { + nr_double_t l = getPropertyDouble ("L"); + nr_double_t er = getPropertyDouble ("er"); + nr_double_t mur = getPropertyDouble ("mur"); + + calcPropagation(0.0); + + deleteHistory (); + if (l > 0.0) { + setVoltageSources (2); + allocMatrixMNA (); + setHistory (true); + initHistory (l * qucs::sqrt(er * mur) / C0); + setB (NODE_1, VSRC_1, +1); setB (NODE_2, VSRC_2, +1); + setC (VSRC_1, NODE_1, +1); setC (VSRC_2, NODE_2, +1); + setD (VSRC_1, VSRC_1, -zl); setD (VSRC_2, VSRC_2, -zl); + } else { + setVoltageSources (1); + allocMatrixMNA (); + voltageSource (VSRC_1, NODE_1, NODE_2); + } +} + +void coaxline::calcTR (nr_double_t t) { + nr_double_t l = getPropertyDouble ("L"); + nr_double_t er = getPropertyDouble ("er"); + nr_double_t mur = getPropertyDouble ("mur"); + nr_double_t T = l * qucs::sqrt(er * mur) / C0; + nr_double_t a = alpha; + if (T > 0.0) { + T = t - T; + a = std::exp (-a / 2 * l); + setE (VSRC_1, a * (getV (NODE_2, T) + zl * getJ (VSRC_2, T))); + setE (VSRC_2, a * (getV (NODE_1, T) + zl * getJ (VSRC_1, T))); + } +} + + + // properties PROP_REQ [] = { { "D", PROP_REAL, { 2.95e-3, PROP_NO_STR }, PROP_POS_RANGEX }, diff --git a/src/components/coaxline.h b/src/components/coaxline.h index 13b15b30..1c4e6801 100644 --- a/src/components/coaxline.h +++ b/src/components/coaxline.h @@ -37,6 +37,8 @@ class coaxline : public qucs::circuit void calcAC (nr_double_t); void calcNoiseAC (nr_double_t); void saveCharacteristics (nr_double_t); + void initTR(); + void calcTR(nr_double_t); private: void calcPropagation (nr_double_t);