First Order RL Circuit #1 (yet another platform to model G&L's SIM)

A simple first order RL circuit (resistive-inductive) having some of the properties of G&L's SIM model. 

Update 2016.04.21: SIM10 is a post with  an op amp implementation of the circuit, which also implements both instantaneous rates and accumulated dollars per period (effectively average rates) in one simulation.

Update 2016.04.14: I implemented it. Try this link to see it in action. Here's a smaller version for posting (http://tinyurl.com/j9rzyvk). (See figure 2 at the bottom of this post, or with labels, it's Model #3 here [4]). Close the switch on the circuit and watch the scopes at the bottom. From left to right they are Vs = g(t) (see comments for how this relates to G), i3 = Y, i31 = T (upper component of i3, through the 0.6 ohm resistor), i1 = H. Time step on this one is 2 ms (you can adjust that in the options menu under "other options" ... along with the simulation speed on the right hand side bar).

What happens when you open the switch again (after having had it closed) is unsatisfying... it'd be nice to see taxes continue to eat away at H, but instead the only current available is i2 (in the opposite of it's usual direction). Hmmm... I have to think about that. I've now thought about it: Update to this update (2016.04.16): I fixed this by adding a SPDT switch and an extra wire, so that the system's time constant doesn't change when the voltage source is switched out of the loop. I had to move the location of my $i_3 = Y$ current to be along the top so that it measures the current with either the battery switched in (government spending = 20 dollars / period) or switched to the plain wire (government spending = 0 dollars / period).

I also have versions with the model saved as text blocks. I had to move them to a MathJax free page because they contained dollar signs. The second one recorded there has labels, which don't seem to work in the link variety of model descriptions (like the one above). Follow the directions on that page for cutting and pasting the text to use them.

Figure 1: 1st order RL circuit

First some preliminaries: The equation for the resistance of two resistors in parallel:
$$R_{total} = \frac{R_a R_b}{R_a + R_b} \tag 1$$
For two such resistors, I'll write for their total resistance $R_{total} \equiv R_a || R_b$.
One can see by inspection [1] that the pole of this system is thus at:
$$a = -\frac{1}{L} (R_1 + (R_2 || R_3))\tag 2$$
and thus the time constant $T_c = -1/a$ seconds.We're of course taking $i_1$ to be the state, utilizing the formula for relating the voltage across and current through any inductor: $v = L \frac{di}{dt}$.

Next we can read off the steady state currents by inspection (assuming $V_s$ is a scaled unit step):
$$\bar{i_1} = \frac{V_s}{R_1} \frac{R_1 || R_2}{R_3 + (R_1 || R_2)} = -\frac{b}{a} V_s \tag 3$$
Where that second equality is a general result for any 1st order single state stable system (i.e. $\dot{x} = a x + b u$). The other steady state values are:
$$\bar{i_2} = \frac{V_s}{R_2} \frac{R_1 || R_2}{R_3 + (R_1 || R_2)}\tag 4$$
$$\bar{i_3} = \frac{V_s}{R_3 + (R_1 || R_2)}\tag 5$$
Where we've already determined $a$ in $(2)$ and $b$ is the usual state space multiplier on the input (the input being $V_s$ in this case) in the state differential equation. Then we can read off the initial currents at $t=0$ assuming that they and the voltage are all 0 for $t < 0$:
$$i_1(0) = 0 \tag 6$$
$$i _2(0) = i_3(0) = \frac{V_s}{R_2 + R_3} \tag 7$$
If we take $i_2$ and $i_3$ to be the measurements of this state space system (imagine there are amp meters in series on those paths), we can determine their respective $c$ and $d$ state space measurement constants (I'll just call them $c_2, c_3, d_2$ and $d_3$ in this case rather than resort to matrix notation). First of all, given $(6)$ and $(7)$ we can see right away that:
$$d_2 = d_3 = \frac{1}{R_2 + R_3}\tag 8$$
Now let's nail down $b$: from $(2)$ and $(3)$ we have:
$$b = \frac{1}{L} \frac{R_2}{R_2 + R_3} \tag 9$$
Now we can use $(4), (8)$ and $(9)$ to find $c_2$ and $(5), (8)$ and $(9)$ to find $c_3$ and we're done! Then we just need to pick values for $R_1, R_2, R_3$ and $L$ [2] such that for $V_s = 20\, u(t)$ (where $u(t)$ is the unit step and 1 period = 1 second), $i_1$ matches the behavior of $H(t)$ (from SIM), and $i_2$ and/or $i_3$ matches the behavior of one or two of SIM's measurements (i.e. $Y, T, \require{enclose} \enclose{horizontalstrike}{Y_D\; \text{or}\; C}$). [3]

Roger, are you up for the task?

Consulting my SIM7 post, I see that unfortunately none of the measurements have the same value for $d$, thus $(8)$ means we can at most model one SIM measurement with this circuit. Still, it gives us enough flexibility to put the measurement we choose to model in proportion to the state $i_1$ to precisely model SIM in that regard.

And we can make parallel sets of resistors out of $R_2$ and/or $R_3$ to give us more than enough flexibility in that regard later (I'm assuming we keep  using currents for measurements, but you could use voltages as well). I bet we could model all the measurements of SIM by such a procedure. [maybe, but not exactly that procedure only] [3]

Update 2016.04.14: from a comment below dated April 14, 2016 at 1:52 PM, I have the values to model Vs as g(t) (see comments), i1 = H(t), i3 = Y(t), and then dividing R3 into parallel resistors R31 and R32 which together have the same resistance as R3, i31 = T(t) (where i31 is the current through R31 (and i32 is the current through i32) and i31 + i32 = i3).

R_1 = 0.1 ohms
R_2 = 0.4
ohms 

R_31 = 0.6 ohms 
R_32 = 0.15 ohms
L = 1.151170249 henrys
R_3  = (R31||R32) = 0.12 ohms (not a resistor in its own right anymore: replaced by R_31 and R_32)

Ts = 1 period = 1 second
Vs = u(t)*20 volts, where u(t) it the unit step

Figure 2: Circuit diagram from online circuit simulator www.falstad.com/circuit/

Update 2016.04.16: After adding the single-pull double-throw (SPDT) switch so that Y, T and H behave like they should once the 20 volt battery is switched out (i.e. G drops from 20 dollars / period to 0 dollars per period), the circuit looks as follows (figure 3). See my description up top.

Figure 3: SIM circuit model with SPDT switch added for better "realism" when the voltage (G) is changed from 20 v to 0 v

Read my description for the labeled version of the SPDT model (Model #3) to see that there's a bug with the labeled version that requires you to add back Scope 4 (H = current i₁) before you can see the above picture. I added a non-embedded label for Scope 4 above it as well.

Figure 4: Showing the results of editing the voltage source and picking a square wave and then setting the switch to 0 v
Figure 4 shows the result of editing the voltage source to be something different. You can edit the voltage it produces on the fly why it's running, but you can also change it to a different kind of voltage source, such as a triangle, square, sine wave or pulse generator. Above I've selected square wave. You can give these waveforms a DC offset so G never goes negative. Here's a link to an implementation of the above parameters. The screen capture shows what happens after I let it run for a while with the switch set to the voltage generator, and then return the switch to the right-hand position where the voltage source is bypassed (so you can start to see the decay in current levels in the three right hand plots, corresponding the the voltage dropping to 0 in the far left plot).

Update 2016.04.17: Here's an op amp version of SIM with G, H, Y, T, YD and C all implemented. The text version is Model #4 (and it doesn't have the circuit as well centered for some reason). It's on the page with the other text models (see link above). There are no labels yet on the text version.

Roger Sparks has a similar page  up here.

-----------------------------------------------------------------------------------------------------------------------------

Notes:
[1] You may wonder how I saw that "by inspection." Here's the trick: replace the voltage source with a short circuit (so no input signal), and then imagine that the inductor L already has a current flowing in it at $t=0$. That would be our initial state (which because it's a stable 1st order system, we know will decay exponentially). Now look at the rest of the circuit from L's point of view: it just looks like a resistor. Once we know what that is, then our pole is at $-R/L$ for a 1st order RL network. Why? Because $v = L di/dt = -i R$, so $di/dt = -i R/L$ and we all know the homogeneous solution to that by now: $i(t) = e^{-t R/L} i(0) u(t)$ where $i(0)$ was that initial current I mentioned and $u(t)$ is the unit step. Look what's playing the role of $a$ (i.e. our usual pole = the complex frequency) in the usual $e^{a t}$ 1st order homogeneous solution.

[2] Four equations for four desired system constants ($a, b, c$ and $d$) in four unknown parameters. Sounds like a match doesn't it?

[3] Turns out I can't do $Y_D$ or $C$ in the framework of circuits like Figure 1 or Figure 2. See comments below for an explanation. I'm sure they can be done, but I need to think about what the circuit looks like a bit more.

[4] The www.falstad.com/circuit/ website is great!... but there are a few bugs. You can't put labels in a circuit you post as a link. So in you want labels it has to be stored as a text string.

119 comments :

  1. Tom writes as a comment at April 12, 2016 at 9:29 PM

    "The analogy I was thinking was the following:
    Vs is G
    i1 is H (the state)
    i2 and i3 are two distinct measurements (outputs).

    The diagram could be simpler and still give non-zero A, B, C and D state space constants, but in this case it gave just a enough flexibility to be interesting I thought."


    Hmmm, Vs = i3*R3 + [(i1*R1+i1*zL) = i2*R2] for all time periods. i1*zL is a transient visible until the system reaches stability. Then i1*zL disappears. The current i will start small and grow as time passes and i1*zl decays.

    I think I would call i3 "the state". "i3" shows all the current flowing at all times.

    But you say, if we removed Vs, L would decay and provide a source of voltage for a while. True. The resulting current would not flow through R3. It would flow through R1 and R2. Hmmm, that would be a system without government. It would soon stop. LOL

    Hmmm, maybe this is an excellent analogy.

    ReplyDelete
    Replies
    1. "But you say, if we removed Vs, L would decay and provide a source of voltage for a while. True. The resulting current would not flow through R3."

      I didn't say to just remove it, but to replace it with a short. The short will let current flow through $R_3$. $R_3$ will look like it's in parallel with $R_2$ in that case (from L's point of view).

      I'm pretty sure that the way it's set up $i_1$ will be analogous to $H$. It will have a step response that looks like a scaled version of $1 - e^{a t}$ and an impulse response that looks like a scaled $e^{a t}$. The other two currents will have step responses that are $i_1$ (scaled) plus a constant. check it out for yourself.

      Delete
    2. Here's why $i_2$ and $i_3$ can't be the states of the system: Look at how we set up a canonical SISO state space system:
      $$\dot{x} = a x + b u\\
      y = c x + d u$$
      Thus $x$ always integrates $b$ times the input $u$. There's no way for a scaled version of $u$ to show up in $x$. Only it's integral shows up in $x$. $y$ can get a scaled copy of $u$ added in as a component. That's just like our system above: $i_2$ and $i_3$ have as a component a scaled copy of $V_s$, but $i_1$ does not: it only has such a scaled copy in it's steady state. That's because it has L in series with it. L ensures that $i_1$ cannot change instantaneously (unless $V_s$ is truly an impulse (a curve with area > 0 in time = 0)... an infinitely high spike).

      Delete
    3. ... impulse = Dirac delta. So what I'm saying is the way we write a state space system ensures that only $i_i$ (in terms of currents) (and scalar multiple's of it) can be the (one and only) state of this system with exongenous input $V_s$. If you want to fold $V_s$ into the system, then all bets are off, because $V_s$ as an unit step is a scaled version of $1/s$ (a single state) but $V_s$ as a general function could have an unlimited number of states in it.

      Delete
    4. Here's my challenge to you Roger: can you fill in the gaps I left? Can you complete the expressions for $i_2$ and $i_3$? Can you find values for $R_1, R_2, R_3$ and $L$ (the parameters) so that with $V_s = 20\,u(t) volts$ and our time period = 1 second you can make $i_1$ reproduce $H$ with amps replacing dollars? And then pick either $i_2$ or $i_3$ to match in amperes (for dollars) any one of $Y, T, Y_D$ or $C$?

      I'm going to do that myself later (when I get a chance), but if you want to beat me to it, be my guest. I'd be very interested to see what you come up with! :D

      I'll give you a hint: I've already done exactly that, expect without adding in a measurement current, in evaluating Jason's RLC circuit analogy in terms of $H$. I used an RL circuit there too (I dropped the C, and replaced it with a short). To add in an analog for the measurements required a more complex circuit, so new values will need to be selected, but you can use my answer there in the comments to pick a value for L (it should be the same) and to tell what R1 + (R2||R3) should be.

      Delete
    5. ... here's an even bigger challenge (but I think it can be done): can you improve my circuit here so that it produces not just the state (H) and a single measurement of SIM, but ALL the measurements from SIM? I'm sure it can be done for a circuit in terms of currents, an applied exogenous voltage (unit step) and some combination of resistors in a network. The question is what will it look like? Think about that one for a bit.

      Delete
    6. ... and then can you change it to an RC circuit, change to milliamps or millivolts = dollars, and change the time period to be anything you'd like... and then go buy all the components and built it?... and then put a square wave signal generator in for $V_s$ and look at the outputs on a scope and ensure that indeed you are reproducing SIM? ... and then take a bunch of screen captures and post them? :D

      Delete
    7. "I'm pretty sure that the way it's set up $ i1 $ will be analogous to $ H $."

      SIM shows in the steady state that $ Y = G + H $ .

      Am I correct? You are saying that $ i3 $ would be $ Y $ and $ i2 $ would be $ G $?

      Delete
    8. Close... G will be the exogenous source $V_s$. You can choose to model one of Y, T, YD or C with either $i_2$ or $i_3$. I explain in the post why you can only choose one measurement to model in addition to the state: because the "d" scalar will be the same for both $i_2$ and $i_3$, which is not the case for any pair of SIM measurements. You'll have to construct a more interesting network of resistors to allow modeling of more than one SIM measurement at a time. Still though, a single inductor should do the trick.

      Delete
    9. Another challenge: the way I've stated it you're only trying to match SIM's output at the sample times, but what if you wanted to obey SIM's accounting equations over ANY interval of time? Then you could switch to measuring charge (in coulombs) and let the currents $i_2$ and $i_3$ represent instantaneous rates of charge movement (which is what amperes are after all). This will require a slightly different set of choices for the resistors... but L should still be fine. Kirchhoff's laws will become your accounting identities! :D

      Delete
    10. To make the analogy better, I could have a circuit with an exogenous current source rather than a voltage source. Then we could think of coulombs as dollars.

      Delete
    11. None of the currents can be G because unlike G the currents will all have an effect from L (that exp(at) curve). G doesn't care about L, thus it can be a step.

      Delete
    12. BTW, I left you a Bode plot comment back on my page with my questions about your dashpot diagram.

      Delete
    13. I certainly need to think about this some more.

      It seems to me that $ iv = i3 $ . This would make $ i3 $ an analog of $ iv $.

      Delete
    14. I should have said " This would make $ i3 $ an analog of $ V $ ."

      Delete
    15. Or more exactly "This would make $ i3 $ an analog of $ Vs $ ".

      Delete
    16. Think about it this way... after Vs steps up to 20 volts, i3 has immediate current flow... however as time passes, the inductor L will start to let more and more current flow. I suggest you work it all out for yourself and see. Write down all the equations and solve them (you'll have to draw in some voltage drops around the circuit):
      i3 = i1 + i2
      V3 = i3*R3
      V2 = i2*R2
      V2 + V3 = Vs
      $V_L = L di_1/dt$
      V1 = i1*R1
      $V_2 = V_1 + V_L$
      etc

      Delete
    17. ... I think those equations cover the whole lot: seven unknowns (V1, V2, V3, $V_L$, i1, i2, i3) and seven equations. Just eliminate all the unknowns except i1 and solve. Then you can back substitute to find i2 or i3.

      Delete
    18. ... assume Vs is a unit step and that everything is 0 for t < 0.

      Delete
    19. ... back in the day (when I was an undergrad) we used a program called "SPICE" or "PSPICE" to simulate simple circuits. I figure there's got to be an open source or web-based replacement for that now. My first Google try came up with some interesting choices, e.g.:
      http://www.partsim.com/
      https://www.circuitlab.com/
      Hey, this one looks pretty cool: you can edit your circuits right there on the website:
      http://www.falstad.com/circuit/

      Delete
    20. Roger... that website is very cool!... you should give it a try. You can build my circuit and see what it does. I'll do that later myself if you don't. ;)

      Delete
    21. ... there may be something like that for simple mechanical systems with springs, dashpots and masses... but I didn't see one yet. I saw some people using simulations of circuits to simulate those things (a two tiered simulation). If you find one, you can build your dashpot system and check it out! ;)

      Delete
    22. Above I wrote:

      "Look at how we set up a canonical SISO state space system:"

      That should be:

      "Look at how we set up a canonical single-state SISO state space system:"

      Delete
    23. I like your circuit analogy. I notice that

      $ V_L = Ldi_1 /dt $ so

      $ di_1 = V_L dt/L $

      At startup (or stop), this causes $ i1 = di $ so at startup, $ i3 = di + i2 $ .

      I may work first on directly using $di$ to find the solution directly, thinking that it is a better match for my Eq. 10.

      I need to break for a while today, to get other things done. Tomorrow I will be gone for most of the day (with a glance at the computer in the afternoon, I hope) and then gone again Friday until afternoon.




      Delete
    24. Yes, but recall that di is infinitesimal, so i3(t=0) = i2(t=0). Recall that if you can boil all the equations down to:
      $$di_1/dt = a i_1 + b V_s$$
      Then the solution for $i_1$ we know because we've solved that problem before (when $V_s$ is a step).

      Delete
    25. Is it almost trivial? The time increment is the current increment. $ V_L / L $ is a constant for each time period IF we know $ V_L $ and we do. It is 20 for each time period in SIM.

      Delete
    26. I'm sure that $V_L / L$ is not a constant. $V_L (t=0) = V_2(t=0) = R_2 V_s(t=0) / (R_2 + R_3) > 0$, and it exponentially decays to zero as $t$ goes to infinity.

      Delete
    27. L is a constant, and the inductor will not pass any current at t=0, thus it will have a voltage drop across it. As t goes to infinity, the inductor becomes the same as a wire (to a DC input) and thus will have no voltage drop across it.

      Delete
    28. Yes, you are right. But it is also true that SIM looks at 20 applied in one period and reports the divisions for that period. Therefore we can apply the 20 as if it were true for the entire period and find what the new current ratios would be.

      I think we could say that the delay is a distraction. If we applied the extra 20 volts, and if we were only interested at time zero and time plus one (two measurements), then we would immediately jump from zero to whatever the 20 volts finally stabilized at. We just pick the time period to accomplish that.

      I tend to write before putting my words to the test. Which is the case when I say that this full period stabilization is what my Eq. 10 is reporting. It would be reporting $ i3 = iV_s = Y $ for the end of each period.

      Delete
    29. Yes, I am beginning to agree that $ i1 = H $ . We think to ourselves that a new voltage level changes the amount of $ H $ stored in the induction. Still thinking the whole period, the amount of current stored in $ L $ is the $ \sum{di} $ over the whole period from zero measurement to later measurement at time one.

      Then, for the household system, we have four components required:

      1) Money = $ iH $

      2) Money storage = $ LH $

      3) A method of measuring $iH = V_{RH} / RH $

      4) A method of dividing between sectors = R1 and R2

      We don't usually think of an antenna as an energy storing device. However, a single picture of an active half wave antenna will show one complete period's storage of energy (if you catch the picture at the peak). The same thing will be true of our induction device.

      The more I think, the more I like your first order circuit as a model for the two sector economy. Thanks for presenting it.

      Delete
    30. Think of continuous time G (let's call it g(t)) as a constant rate starting at t=0. The time from t=0 to t=1 (measured in "periods") is called "Period 1" by G&L in their results table (or that's how I think of it anyway). So by "Period 2" (which starts at t=1), integral of g(t) over one sample period = 20, and it continues on at 20 forever after that. So G is integral of g(t) over one sample period looking backwards (i.e. over the preceding window of time of length 1-period (I call that Ts) up to the current time. Make sense? So you're right: it's a distraction. For purposes of this exercise, $V_s(t) = g(t)$ rather than G, but that's not a big deal. It's still just a step function of magnitude 20.

      Regarding i3: i3 is whatever you want it to be. It doesn't have to be Y. We can select parameters (R and L values) such that i3 represents T, YD or C as well, and we can do that without changing the fact that i1 represents H. Specifically, we don't change L, and we can change R1, R2 and R3 in any manner as long as R1 + (R2||R3) stays fixed, and we won't change our model of H = i3. So first pick L and R1 + (R2||R3) to make i1 a model of H and then you're free to change R1, R2 and R3 however you like subject to the constraint that R1 + (R2||R3) stays constant. Your choice for those R parameters will determine what i3 models (Y, T, YD or C... or none of those!).

      Delete
    31. "The more I think, the more I like your first order circuit as a model for the two sector economy. Thanks for presenting it." You're welcome! I actually find these simple circuits easier to visualize rather than the mechanical equivalents sometimes. They certainly are easier to draw a diagram of (IMO).

      Delete
    32. ... plus if you want to see "movement" that website I link to above is great for that! It represents the currents going through the wires even. Very cool!

      Delete
    33. Modifying what I wrote above a bit, you might find that either i2 or i3 is more appropriate for some of the measurements. For example, I'm not sure you can model T with i3, since I think i3 >= i1, and if i1 = H, we know that T < H. However there's no such restriction on i2 (i.e. it's possible i2 < i1 = H). However if you divide R3 up into a set of N parallel resistors such that $(R_{3_1} || R_{3_2} ||\, ...\, || R_{3_N}) = R_3$, all with associated currents, $i_{3_n},\; s.t.\; i_3 = i_{3_1} + i_{3_2} +\, ...\, + i_{3_N}$ then you could find one of those components of i3 to match T I'm sure.

      Delete
    34. Roger, what do you mean by $iH$? Do you mean $i_1$? Also recall that an inductor actually stores energy in its magnetic field. If there was no resistance in a closed circuit with just an inductor, that magnetic field would prevent the current from diminishing.

      Delete
    35. You write

      " So by "Period 2" (which starts at t=1), integral of g(t) over one sample period = 20, and it continues on at 20 forever after that. So G is integral of g(t) over one sample period looking backwards (i.e. over the preceding window of time of length 1-period (I call that Ts) up to the current time."


      Are we finding the same meaning here? I understand the USD 20 SIM government increase as a method of integrating on a annual basis. Thus, if we have two periods, each with USD 20 spent by G, this is an integration so over the two year period, G has spent USD 40.

      My Eq. 10 takes advantage of that integration (two periods in this example).

      "Roger, what do you mean by $iH $ ? Do you mean $ i1 $ ? Also recall that an inductor actually stores energy in its magnetic field. If there was no resistance in a closed circuit with just an inductor, that magnetic field would prevent the current from diminishing.


      I wrote $ iH $ trying to distinguish the household unique part of the circuit. And, yes, the magnetic field in the inductor. We can think of that magnetic field as being current stored over time. If the inductor was half wave length long, it would store one entire half wave of the AC signal. Now here, we are talking about a DC signal. We only need the time period to be long enough to fully charge the magnetic field.

      Does that make sense?

      Now SIM has two integrators: 20 replicated each period and an inductor which fully charges each period.

      Does that make any sense?

      Delete
    36. Re: G: I think we're saying the same thing. In Figure 1 here (SIM9):
      http://banking-discussion.blogspot.com/2016/04/sim9-highlighting-difference-between.html
      what I called g(t) above would be the u(t) (light blue) curve which is a unit step. Then if we had a G(t) (continuous time) it would follow the dark blue curve (integral of u(t)) up to where it crossed the light blue curve, and then follow the light blue curve horizontally. Now if we sample G(t) at the sample times n*Ts, then we have G[n] = G(n*Ts) and that's G*L's G in SIM.

      But no matter, it's u(t) (or g(t)) I'm interested in in the circuit: just the unit step.

      Magnetic fields: yep.

      I prefer to think of G as an exogenous input to the single integrator economy, but yes, if you want to include G (or rather g(t)) in the economy, then it's transfer function is 1/s, which is another integrator... which you could do at the end as well (integrate the rest of the economy's impulse response).

      But if g(t) should have some other shape, like arctan(t) for example, or (in the frequency domain S-plane) a 4th order polynomial divided by a 6th order polynomial... then you can't say it's (just) an integrator anymore.

      Delete
    37. Here's how you can use Laplace transforms to solve time domain problems: say you want to know the output y(t) of a system p, to an input u(t). You could solve the convolution integral of u(t) and p(t) where p(t) is the system's impulse response. That might be hard. Another thing you can do is find the product Y(s) = P(s)U(s), factor that as necessary, and look up the inverse Laplace transform of the result (or the constituent parts of the result) and that will be your y(t). So rather than make a list of all the ways the SIM economy reacts to different government spending functions g(t), you can simply calculate the transfer functions: Pi(s) = Yi(s)/G(s) (i = 1,...,4 for SIM), and then before even applying any particular g(t), you'll already know a lot about what possible things can happen just based on the transfer functions. You'll know if they're going to be stable, if they'll oscillate, and if subjected to an oscillating input, what the phase and magnitude of the response will be for each frequency of oscillation. It also simplifies finding the answer for any particular g(t): you just need to look up g(t)'s Laplace transform, calculate Pi(s)*G(s), factor (or otherwise express in a more convenient format), and take the inverse Laplace transform (again by table), and voila'... you'll have your set of yi(t).

      Delete
    38. ... so, for example, if your model of the economy has a pole in the right half plane, you know that no matter what the input (government spending function) is you apply, it's gong to produce an unstable output (an output which grows in magnitude without bound... or until something breaks)... unless that input has a zero very carefully placed to cancel that pole (which you know isn't going to happen, since it has to exactly cancel it). Better to add a feedback loop and use that to move the pole to a better location (like anywhere in the left half plane for a start).

      Delete
    39. _A circuit problem._

      I'm trying to put taxes into the circuit without success. My solution is to add a fourth resistor R4 parallel to R2. R4 has a size to allow R3 current to satisfy the relationship $$ i3 = i1+i2+i4 $$ .

      We need to add the tax rate into the calculation to bring stability. $ Tax = \theta i3 $ .

      The SIM problem is initially defined as $ G = 20 $

      The SIM problem is further defined as $ H = (1 - \alpha 1) Income $

      I think $ \text{ Respent in period } = \theta \alpha 1 G $ . Then $$ \text{period income} = G + \text{Respent in period} $$

      We choose three resistors that give us $$ i3/Y = Y = H + G + \theta \alpha 1 G $$ . These three resistors are in parallel and I have not yet worked that out.

      [It is getting late, I hope I have the math worked out correctly but probably will not get it checked until Friday afternoon or later.]

      Finally, the SIM problem is further defined that once saved, only $H \alpha 2 $ is respent during the period. That definition will not influence the resistor choice which is a steady state solution. It might affect the size of the inductor if we wanted to examine the shape of the dynamic curve more carefully, but I have not confirmed this speculation.

      Delete
    40. "These three resistors are in parallel"

      That should be "These three resistors are in parallel in the steady state condition ". R4 is in parallel with R2.

      Delete
    41. Roger, try putting a resistor in parallel with R3 instead. The problem with R2 is that the equivalent system measurement coefficient for i2 is c2 and c2 < 0. SIM has no "c" coefficients that are < 0. Thus you're stuck with breaking i3 up into separate paths. You have to do that because i3 itself is always > i1, and taxes are < i1. If you go that route you can make the current through one of the parallel resistors replacing R3 as small as you want. Call the two resistors replacing R3, R31 and R32, and likewise define C31 and C32 and D31 and D32. Now say i31 is the current we want to represent T. We know what C31 and D31 have to be (see my SIM7), thus we know their ratio too. It turns out C31/D31 = R2. So now you have one of your resistors! You also know the ratio of steady state i31 to steady state i1 (i.e. steady state T to steady state H... call that k, where k < 1). Also D31 = R2*k/((R1+R2)(R2+R3)). You know everything there except R1 and R3. Use that to write R1 in terms of R3. Then use the steady state gain value of i1/Vs = R2/(R1*R2+R1*R3+R2*R3) (again, we know this value). Substitute R1 for the expression for it in terms of unknown R3. Everything else we'll again know, so now you can solve for R3, back substitute to solve for R1. Then you can solve for L since b = R2/(L*(R2+R3)), and we know b. Then you have R1, R2, R3 and L, but R3 no longer exists... it's R31 || R32. It turns out R31 = R3(R1 + R2)/(R2*k). Once you have that, you can find R32, and you're set. I haven't solved the whole thing myself, and there's at least one quadratic in R3 you'll have to solve... so hopefully that works out. Anyway, good luck!

      Delete
    42. Good Morning!

      Something went bad with my computer this morning. Lost about an hour and needed to use Restore.

      I need to think about your comment.

      I did work the other way to find a ratio of G. The result is

      $$ \frac{1}{Y} = \frac{1}{H} + \frac{K}{G} $$

      where $ K = 1 + \frac{1}{\alpha 1 \theta } $ .

      I think that that this is a unique circuit, defined by K. It is an integrating circuit in the sense that i3 is the sum of the current in other resistors. I have not yet proved it, but I think this four resistor circuit embodies my Eq. 10.

      If so, we change i by changing the voltage. Just use sequentially reduced voltage steps and add sequentially to find the steady state solution.

      Hmmm, my intuition tells me that your suggestion to change modify R3 would also work. Only the value of K would be different.

      Hmmm, again my intuition, but it takes four resistors in this combination to be a unique ----- No, there is something about combining two resistors into one that loses information. Maybe it is the ability to -----Ok, you probably need one resistor for each constraint placed on the system. We have two obvious constraints, alpha and theta. We also have the constraint that tax and H are related. I will need to think more about the interaction between constraints and number of resistors.

      I'm still wondering what I am looking for here. With four resistors, I think of the A, B, C, and D of the state-space system and matrices.

      You will probably have it all worked out by the time I return home briefly this afternoon. I won't get much done unless something pops into mind during quiet periods as the day passes. That sometimes happens.

      Good Luck to You!

      Delete
    43. Try this idea: The fourth resistor represents the unknown current that results when the three resistor system is upset with a predefined current in one member. i.e., the fourth resistor represents delta i. Weird, especially the delta i part.

      Delete
    44. ... you know what's easier still? Circuits with op-amps: once you change one thing it doesn't affect the whole rest of the circuit! ;)

      Delete
    45. Try this (I just worked it out, so it may not be correct): Use i3 to model Y. We know the C and D for Y (see SIM7). Call them C3 and D3.

      R2 = C3/D3

      R3 = 1/D3 - R2

      we know steady state Y / steady state H, call it Yss/Hss

      R1 = Yss/Hss - R2

      L = C3/b (and yes, we know b from SIM7 too)

      So now you have a model for H and Y!

      Now to add T:

      Implement R3 by two resistors in parallel: R31 and R32. Let the current though R32 model T:

      R31 = R3/theta

      R32 = R3/(1-theta)

      You're done!

      If it's correct. You want to check that? Does the value "a" which we also know from SIM7 work out correctly?

      a = -(R1R2 + R1R3 + R2R3)/(L(R2+R3))

      Delete
    46. R2 = alpha2

      R3 = 1 - alpha2(1-theta) - alpha2

      R1 = alpha2/(1 - alpha1(1-theta) - theta)

      Then use the equations for R31 and R32 above, and then consult SIM7 to find b, and plug in to find L.

      Oh, well, let's just do it: define X := 1 - alpha1(1-theta)

      Then L = (alpha2^2)*X*theta*Ts/(ln(1-alpha2/X)*(theta-X))

      Where Ts=1 (1 second) and ln(.) is the natural log.

      You should come out with totally ridiculous values, like L = 1.5 henry's or so, and the R will all be less than 1 ohm I think. Good luck trying to find a 1.5 henry inductor capable of handling 80 amps of current!

      OK, so then you'll need to scale everything to practical values, and/or perhaps change to an equivalent RC network and/or change what 1-period is.

      How do I know what L is (approximately... order of magnitude anyway)? Well I already worked this out once to just model G and H. Here's the comment I calculated those values in. I'm not positive they won't change with this new circuit... maybe L will be the same, and maybe that R there is related to some combination of the R values here. I suspect they will change... because R there was used to establish the steady state for H and then L was selected to make the time constant come out right... but in this case it's a little different.

      Delete
    47. BTW, I didn't check any of the above... I just thought of that in the shower this morning (actually I'd come to the conclusion last night that really the only measurement you can model with the circuits as is, is Y = i3, and that's because i3 > i1 in steady state, and Y is the only one that qualifies (since H has to be i1)). So when I saw you having trouble with T I knew you'd have to replace R3 with parallel resistors to do it. i2 can't model any of them, because it'll be an exponentially decreasing function + a constant. (I'm pretty sure that's true about i2... but check for yourself). None of the measurements look like that. That's because C2 will be < 0 (as I mentioned above). (C2 and D2 are the system measurement constants in the state space equations for i2). Unfortunately shooting directly for T was a bit complicated... I should have just stuck with Y = i3, because then we know that T = theta*Y... and that's conceptually easier to work out the algebra for. That was my shower insight... so no quadratic equation involved that way. I think!!! Please double check and see if I'm correct. I did zero checking.

      Also we get two measurements that way! Unfortunately they are restricted to just Y and T. So I was wrong about being able to model the other two (YD and C) with the circuit as is. Can you work out a circuit to model those? I wouldn't worry about doing all of them in one shot, just pick one. If you can do one, then you can do the other. Actually I think the same basic idea will work: split R3 into parallel resistors. Then in one of those parallel paths the current can be set equal to i1 in steady state (that's what you need for both YD and C). Then you can change other things to make the current through them at t=0 work out to what you need. That's my story ... and I'm sticking with it, until I'm proved wrong. =)

      ... still, I want to see this plugged into that online circuit simulator and see it actually work. That's my goal... again, if you beat me to it, then great! (I know it'll be a bit before you can come back to this... but I've got stuff to do to!).

      Delete
    48. My formula for L above is off: if you already have b and C3 calculated, then L = C3/b is easiest, but if not:
      L = (alpha2^2)*theta*Ts/(LN(1-alpha2*theta/X)*(theta-X)*X)
      That's straight from Excel
      Here are how the other values work out I think:
      R_1 0.1
      R_2 0.4
      R_31 0.6
      R_32 0.15
      L 1.151170249
      R_3 0.12 (not an actual resistor value anymore, but = R31||R32)
      (straight from Excel, thus the "_" in the names)

      Also my formula for R1 is wrong up above, it should be:
      R1 = (Yss/Hss - 1)*R2

      Delete
    49. ... next I will add a 1-ohm resistor in parallel with everything else across Vs (so it won't affect anything else), and the current though that can be g(t), where g(t) integrated over a window of length Ts is G(t) and where G(t) at the sample times is G[n].

      Why would I do that? Because I'd like to have a current to represent G, Y, T, YD and C (well, just G, Y and T so far). Then I can pick a new set of R and L vales such that I can model dollars as coulombs instead of amps. Then the currents i3, i31 and the new ig (The subscript g for the function g()) will ALL represent instantaneous rates. As it stands now (with the above values) i3 and i31 represent an average rate over the preceding period of length Ts (Ts = 1-second in this case).

      But back to that future circuit: then the wires of the circuit itself will be enforcing SIM's accounting laws over ANY time interval (not just Ts sized ones ending on sample times). Unfortunately H will still have to be in amps. I'm thinking of another future circuit where the inductor is replaced with a capacitor, and then H can be the charge accumulated on the capacitor... then 1-coulomb = 1-dollar everywhere in the circuit (I may have to replace my voltage source with a current source though... we'll see). The currents sampled at any time will not match SIM's output (except for H), because instead I'd need a coulomb meter to do that. I don't know if they exist, but conceptually I like 1-coulomb = 1-dollar.

      BTW, my estimate for L wasn't bad, eh? I said on the order of 1.5 Henrys, and it came out about 1.15. It still needs to be 80 amps. You won't find one of those at Radio Shack! Also, like I predicted, the Rs are small... all less than 1-ohm (more problems at Radio Shack, especially rated for 10s of amps... just the wire itself will have to do... but you may need a lot of it).

      Why? To point out with a physical device the difference between averaging-over-a-window and instantaneous models. Does anyone but me care? Probably not. :D

      So I'd love an independent check of the above... I'm more confident in the numerical values than I am in my equations because I typed those into Excel to check them, made errors in typing, corrected them, found some errors in the way I had the formulas printed in the above comment... made more checks, etc. So eventually those are the numbers I came out with and they seem to check out. I'm not 100% positive my Excel spreadsheet formulas match my comments now though.

      Delete
    50. ... BTW, with the model as it stands, i2 = Y - H. Think about what that looks like: H(0) = 0, but Y(0) > 0, in fact I think Y(0) = 38 or so. And Y(inf) - H(inf) = Yss - Hss = 20. So i2(0) = 38, and then decreases to 20. In fact, no matter what resistor values you pick (unless you're allowed negative values) i2 will have this characteristic: it won't increase like any of the other curves. That's why trying to use it to represent a SIM measurement is going to be a problem.

      Delete
    51. ... and because i2 doesn't decrease all the way to 0 means it can't even be used to represent G - T or $\Delta H$.

      Delete
    52. ... one current I've ignored as a "garbage current" is i32 (the other parallel branch where R3 used to be). I guess you can literally think of it as the untaxed portion of Y.

      Delete
    53. Hi Tom, Back for an hour and then up to this dinner meeting. I only have time to glance at your work.

      I considered some false starts during quiet times. Anything further I might suggest would only be intellectual noise.

      I may be back late this evening (with heavy eyes). Hope what you have works.

      Delete
    54. ... Roger, take a look at my update at the top: I implemented this as a circuit model online. Follow the link and then close the switch by clicking on it.

      Delete
    55. ... the update is in the post itself, at the top (in dark green), above the diagram.

      Delete
    56. ... Roger, I notice they have Op Amps in their library of circuit components... that will make implementing these kinds of models MUCH easier!

      Delete
  2. Roger, I should have made this a post. Oh well, I'll put a link in my last post to it (at the top).

    ReplyDelete
  3. Tom, I got home a few minutes ago. Pretty sleepy.

    The circuit and the web site are fantastic. I am looking forward to trying it out.

    Could we have a solution where R3 is divided into two resistors, each in series with either R1 or R2? Think of a Wheatstone bridge. The inductor is in series with one leg and has zero resistance. R3a = R1 and R3b = R2 . I3a + i3b = Y.

    Consider the steady state after the inductor is charged.

    Let $ i1 = H , i2 = G $

    In the steady state, we have

    1) $$ H = \alpha 1 (1- \theta )Y $$
    2) $$ G = \theta Y $$

    The two resistors R3a and R3b will carry the sum of H and G so we can add equations 1 and 2 to get

    3) $$ G + H = \alpha 1 (1 - \theta ) Y + \theta Y $$

    That simplifies to

    4) $$ G + H = Y( \alpha 1 (1 - \theta ) + \theta ) $$

    which is the solution.

    This does not use the inductor at all. We either somehow include it into the solution or we use the SIM term $ \alpha 2 $ to insert the delay mathematically using a spreadsheet.

    Maybe you have already done this.

    I expect to leave as early as 7 AM tomorrow morning. Should be back about 3 PM.

    You are making some interesting progress. We will get this thing solved, I think.

    ReplyDelete
    Replies
    1. Roger, I'm not following you. Maybe you can make a diagram? Or better yet, make a circuit on that website (it's pretty easy to do actually). The main confusion I had is in remembering to use the "Draw" menu after to restore the state to "Select/Drag" (or use the equivalent shortcut) after selecting an element to draw. If you forget, you'll create more new elements (like wires, or resistors, or whatever you last selected to draw). Also, you have to use a context menu (right click) to copy, but you have to use CNTRL-V to paste (elements say)... at least as far as I could tell.

      Actually, I just tried it out again: there are easy shortcuts for drawing wires, resistors and for returning to select mode. They are "w", "r", and "space" respectively. Shoot! I wish I'd noticed that. That makes drawing circuits a lot easier. (and "SHIFT-drag" keeps you in whatever drawing mode you were in, but lets you drag the component momentarily... your cursor shape indicates if you're in Select mode or some drawing mode).

      You can use my circuit as a starting point... like you probably noticed, the encoding for the circuit is embedded in the link itself, so you won't mess anything up (my link will not be affected)... just be sure to save your work by getting a new link or using the other ways to export your circuit on their file menu (I say "their" but that site looks to be the product of one creative individual, named Paul Falstad... however the JavaScript conversion was done by Iain Sharp).

      Delete
    2. There's a ton of other circuits in there pre-made. Look under the "Circuits" menu. Here's a Wheatstone bridge for example. Some of them are very elaborate.

      Delete
  4. http://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.002+6.450009306485581+24+25+43%0As+432+224+432+176+0+1+false%0Aw+432+384+432+448+0%0Al+640+272+640+384+2+1.151170249+0%0Aw+432+256+432+224+0%0Av+432+320+432+256+0+0+40+20+0+0+0.5%0Aw+432+176+640+176+0%0Ar+640+176+640+272+0+0.1%0Ar+704+448+704+176+0+0.4%0Aw+704+176+640+176+0%0Ar+432+448+640+448+0+0.4%0Aw+592+384+640+384+0%0Aw+480+384+432+384+0%0Aw+432+384+432+320+0%0Ap+640+384+640+448+0%0Ar+480+384+592+384+0+100%0Aw+704+448+640+448+0%0Ax+515+478+649+481+0+24+i3b+=+G+=+Yb%0Ax+724+352+788+355+0+24+i2+=+G%0Ax+555+258+618+261+0+24+i1+=+H%0Ax+484+352+615+355+0+24+i3a+=+H+=+Ya%0Ao+4+64+0+34+20+0.00009765625+0+-1%0Ao+12+64+0+33+0.0000762939453125+0.00009765625+1+-1%0Ao+2+64+0+33+0.0000762939453125+0.00009765625+2+-1%0Ao+13+64+0+550+0.0000762939453125+0.00009765625+3+-1%0A

    Hi Tom,

    The link is untested.

    I see that I left out one or two lines of conversions in my solution.

    I am on my way out the door. Sorry but back mid afternoon. Good Luck on this.

    ReplyDelete
    Replies
    1. The link and the circuit function. I'll let you explain it later. The 100 ohm resistor is much bigger than the rest, causing the time constant to be tiny.

      Delete
    2. I forgot to mention not to add labels. They don't seem to function well, and they cause any scopes you put down to disappear. It looks like you used "scope probes" ... but no scope was there. Only one label made it too.

      You can use labels and store them in a text file. Create a page (like I did) without MathJax (the text files use dollar signs), and then just paste your text there. That will preserve the labels and not mess up your scopes.

      Great, I'm glad you had a chance to try it out!

      Take a look at their examples with op-amps: they have integrators, differentiators, etc. It will be easy to construct a complete model of SIM and ALL it's outputs using those because their high impedance inputs keep you from having to redesign your whole circuit each time you want to add something. For example, adding outputs in my circuit above required me to find a new value for L (when I'd already worked one out in Jason's comment's section for a simple model of H alone). That wont' happen with op amps.

      Plus they have ADCs... so it's possible (but probably still too much work) to sample the circuit and show both analog and discrete time happening simultaneously. I'm thinking of a simple sample and hold analog might be better though (controlled by a digital clock). I'll ask the electronic designer at work what to do.

      Delete
    3. It might even be possible to construct a pair of ping-pong integrators that integrate over a sliding interval of time... then I could have everything going on at once! Dollar rates, integrated dollar rates over a sliding window (SIM's true output variables), and a straight integrator for H.

      Delete
    4. This comment has been removed by the author.

      Delete

    5. I made it back early! I think the labels are in but this is a test.

      I will try to fill in the math this afternoon. Hope I can do it.

      Well, try again. The labels seemed to mess things up, just like you said.

      I'll make another page. Probably late afternoon before I get this done.

      Delete
    6. ...or like I say, if you want to keep your labels, just create a page without MathJax like this:
      http://banking-discussion.blogspot.com/p/circuit-simulation-descriptions.html
      Then I can cut and paste your text into the simulator to initialize your model.

      Delete
    7. ... and of course export your circuit as text rather than a link.

      Delete
    8. "I will try to fill in the math this afternoon. Hope I can do it."

      I notice that Octave has a symbolic math package (like Matlab does). You probably have to install it (it's probably not part of the base installation). Plus there's always Wolfram Alpha. =)

      Delete
  5. Here is the new page:

    http://mechanicalmoney.blogspot.com/p/mech-first-order-lr-circuit.html

    The circuit seems to work for me.

    I have not yet completed the solution to the math gaps.

    There is a logic gap that I think I understand but not yet in symbols. Basically, current is measured in units/dt. So is tax units/dt. We can add units/dt but to find the total, we must integrate. So the solution I offered is the sum of the units/dt, which is Y/dt.

    Now I wrote H + W = Y((1-theta)alpha1 + theta) if I remember correctly. I should have written Y/dt instead of Y.

    The solution gives the incremental change in Y for time interval dt. This is the way it was done in SIM. Still not checked out but I think this is correct. Makes sense?

    Must leave for about an hour. Will take a look at your comments after returning.

    ReplyDelete
    Replies
    1. I left some comments for you there. Regarding units/dt: The easy thing to do is just regard G, Y, T, YD and C as dollars per sample period. Since SIM only produces outputs once per sample period, the integrated values of underlying instantaneous curves will be the average rate over each sample period.

      So you can think of them as a quantity (dollars summed over one sample period) or a rate (dollars per sample period). It doesn't really matter too much. I discuss further some slight differences if you want to be exacting about it (because a true instantaneous rate will be slightly different in all those cases, but only just slightly especially when 1 period is approximately 1/6 of the time constant, which is the case with SIM. It'd make a bigger difference if 1 period was 6 time constants!).

      First I'd work out getting all your steady state and initial (t=0: just after the switch is closed) values the way you want them (with appropriate resistor values), and then worry about the time constant.

      Delete
    2. "I should have written Y/dt instead of Y."

      In other words, if you take my advice above, it doesn't matter.

      Think of it this way: if you continued to measure all those (G, Y, T, YD and C) as "dollars summed per sample period" and reduced the sample period to zero, then all those curves would go to 0!

      So that's why I prefer to think of them as rates to keep it simple. Rates that happen to match the summed values per sample period with the default sample period.

      If you go to my SIM2 post, you'll notice you can change the sample period (Ts) and the curves don't change (much) because I'm reporting rates (in dollars per ORIGINAL sample period)... with the sole exception of $\Delta H$, which goes to zero as Ts goes to 0. $\Delta H$ I report on the plot as a true number of dollars summed over the sample period, so clearly as that size of that window drops to nothing, so does the curve.

      Delete
  6. Tom, Maybe I finally have it all together.
    http://mechanicalmoney.blogspot.com/p/mech-first-order-lr-circuit.html

    You are right that it would not make any difference whether Y or Y/dt.

    And you are right about the SIM values as time increments approached zero length. They become vanishingly small.

    All my solution says is that Y is a ratio to the sum of H and G in the SIM model. This ratio is due to taxes and the tendency of the household sector to save part of their money. In SIM, the saved money is respent and resaved in the same ratios in future iterations.

    Does this all finally make sense? It is hard to pin down all the nuances and mysteries but this circuit certainly helps. By expressing the ideas different ways, the mechanics are put to the test.

    I can easily readjust the resistor values to give the current ratios found in first step SIM.

    ReplyDelete
    Replies
    1. "All my solution says is that Y is a ratio to the sum of H and G in the SIM model."

      Can you write that down as a mathematical ratio? I left a question for you on your post about A and B. Perhaps that's the best place to discuss it since your diagram is there.

      Delete
  7. Here is another way of saying the same thing. H and G are the yearly money supply. A velocity term will convert the money supply to GDP.

    ReplyDelete
  8. Tom, I am afraid that the four-resistor circuit doesn't work for you because the inductance is not used to show the time delay. Instead, the four-resistor circuit integrates over the whole time period to report the GDP achieved with an initial amount of money supply, no matter which sector holds the initial amount.

    ReplyDelete
    Replies
    1. That should be "afraid that my version of the four-resistor circuit doesn't work for you

      Delete
  9. Good Morning Tom,

    Thanks for your comments found on my page
    http://mechanicalmoney.blogspot.com/p/mech-first-order-lr-circuit.html

    Your question about my equation 1 was questioning if I meant to use the equal symbol (=) or the three-bar identity symbol? An excellent question. I should, in many cases including this one, be using the identity symbol.

    There are two problems in doing this:

    First, my habit is to interchange the two symbols (incorrect!) with the result that error creeps into my writing. That happened here.

    Second, how do you put the triple-bar symbol into a comment or a blog page? I think with mathjax, you use \equiv.

    There is a way to put unicode characters into comments. I was very proud of myself when I did that one time in a Nick Rowe comment, but now I have forgotten how I did it. A simple process but must be exact. I just spent about an hour seeking Google help without success. HELP!

    OK, back to work. I tried your code in the Falstad circuit and it worked great. I did not understand how to turn the scopes on and off so I had what I inherited. Add inherited and my fumbling resulted in the code offered as I write (I will update it soon.).

    My next task is to solve the equality/identity symbol distraction. Sloppy usage or failure to use the correct symbol is causing a lot of misdirected time use.

    ReplyDelete
    Replies
    1. Roger, I don't recall asking about $\equiv$ (that's the MathJax variety), but Here are some alternatives:

      define x as y
      x is defined as y
      x := y

      And if you want the unicode, I just Googled this "defined as symbol" without the quotes, and the second result on that page actually contains the unicode symbol in the small block of text Google puts under the result... so I didn't even have to open it, I just cut and paste directly from the Google results page: ≡

      Here's the result I'm talking about:

      List of mathematical symbols - Wikipedia, the free ...
      https://en.wikipedia.org/wiki/List_of_mathematical_symbols
      Wikipedia
      For example, depending on context, the triple bar "≡" may represent congruence or a definition. Further, in mathematical logic, numerical equality is sometimes ...
      ‎Symbols by subject - ‎Greek letters used - ‎Mathematical notation - ‎Triple bar

      Delete
    2. ... personally I like this one:

      x := y

      No special symbols needed, and it's compact.

      Delete
    3. ... and Good morning to you!

      Regarding the scope options, just right click on a scope to bring up it's options. And in trying that just now myself I realized something that I hadn't noticed before: just hovering the cursor over a scope causes the part of the circuit the scope references to turn light blue in color and it's connection points to turn into squares, so it's completely obvious what the scope is measuring! Lol... well, in any case, I found a way to label the scopes that's NOT on the options list, and is superior to attempting to put a regular label over the scope (which seems to move from where you'd expect it to be when you try the resulting text circuit descriptor). I will update your diagram with this new means of labeling it. Look at my text to see how did it (you have to edit the text directly). It's how the author labels his scopes in some of his examples. I left a comment for you on your model page demonstrating what I did.

      Delete
    4. Roger, take a look at the upper right corner of my blog now: I added a list of useful symbols. How did I do it? I went to the "Layout" section of blogger, and under the "sidebar-right-1" area I selected "Add a Gaget" and then I scrolled down the list until I found one called "Text" and selected that. Then I pasted the ≡ in there, and then I brought up the Wikipedia page on a useful symbol (delta) and noticed they had the whole alphabet over there in the side bar, so I just grabbed all of them. If you don't like looking symbols up, you could do the same. Or put them on a page so it's not right there on every post of your blog.

      Delete
    5. ... although I think I'll reorder it a bit to put the symbols at the bottom of the sidebar.

      Delete
    6. I'll do that (the list of symbols) but it will take me a while. I'm just not as fast as you! I like your := for identity when we are limited to ASCII characters.

      I am thinking about how to add your inductor to the steps in my formula. Your inductor shows what happens during very step, showing the slow increase to a steady value. One idea was to have a series of resistors to be switched in sequentially. I also looked at their timer option and it seems to offer a gate with a duty cycle. I have not examined the triangular wave form in the voltage device, nor the current source option.

      Delete
    7. On my next iteration I plan to replace the inductor with an op amp integrator circuit (look in their Circuits->Op Amp menu). Here's a link (from which I removed their scope labels so it won't screw it up).

      Delete
    8. ...signal on the left (series of step functions) is being integrated on the left (ramp functions).

      Delete
    9. Symbols: just cut and paste mine if you like. There's one in there: 𝕀, which is "double struck" capital I which is what I'm used to for the set of imaginary numbers. But unfortunately it's not a normal unicode math symbol. Everytime I edit that list a 2nd time in a row, blogger thinks it can't understand that symbol. Notice how it's slightly smaller than the other unicode symbols for sets of numbers, like ℝ ℂ ℕ ℚ ℤ? Well it doesn't look smaller here, but there it does, and in Notepad (the simple text editor on my computer) it does. Something is screwy with that one, so you may want to just remove it. I don't know why they don't have one for the imaginary numbers... they have one for everything else. Weird. Anyway, I'm used to writing things like this:

      x ∈ ℝ (x is an element of the reals)
      x ∈ 𝕀 (x is an element of the imaginaries)
      x ∈ ℂ (x is an element of the complex)
      i ∈ ℕ (i is an element of the naturals (i.e. counting numbers {1,2,3,...}))

      etc

      I guess ℤ is the integers and ℚ the rationals (I'd never seen those before), and they had a few others I thought I'd never need (like double struck P for the primes).

      Delete
    10. They even had one (double struck S) for the "Sedenions" which I'd never heard of till just now.

      Here's more. Notice how they relegate 𝕀 to the general class of double struck characters, and don't ascribe to it any special mathematical meaning? Well I guess blogger doesn't always recognize all the characters in that more general class.

      Delete
    11. Adding the inductor: Look at my comment above dated April 13, 2016 at 9:30 AM

      Do you see how I did it? It just appears in one of the seven simple equations. If you then follow my advice there and eliminate all other currents and voltages except $i_1$ and $V_s$ then you'll have $d i_1 / dt = A i_1 + B V_s$. Substitute whatever current you have flowing through your inductor for $i_1$ and you'll have it.

      Delete
    12. ... in writing those seven simple equations (you may have more or less) I just used Ohm's law and Kirchhoff's laws:

      1. V = I⋅R (Ohm's law)
      2. Currents flowing into a node add to zero (Kirchhoff's current law)
      3. The voltage drops around any loop add to zero (Kirchhoff's voltage law)

      And then of course the fundamental equation for inductors:
      $$V_L = L\frac{di_L}{dt}$$

      Delete
    13. ... that last one of course just fits into a one of Kirchhoff's voltage loop equations. In my case that was $V_2 = V_1 + V_L$. Where of course $V_n$ is the voltage drop across the $n$th circuit element (in my case $R_2, R_1$ and $L$ respectively).

      Delete
    14. ... so once you have di/dt = Ai + BVs, then you can figure out what A and B need to be. In my case I already figured that out long ago: $A = 1 - \alpha_2 \theta / (1 - \alpha_1 (1 - \theta))$ and $B = 1 - \theta / (1 - \alpha_1 (1 - \theta))$. So essentially I worked the problem from both ends: one end was complete a month ago. =)

      Delete
    15. Whoops, that's the $A$ and $B$ from the discrete time case. I should have said once you have $di/dt = a i + b V$ (in my case specifically $di_1/dt = a i_1 + b V_s$), then $a = \text{ln}(A)/T_s$ and $b = B a / (A - 1)$ (generally true when going from discrete time to continuous time), and for my case (SIM) specifically $A$ and $B$ are given by my comment above.

      Delete
    16. Try the circuit now. I using the values from my Eq. 1 scaled to give a decay curve that would display a little better. These are the values reached at the end of the first SIM period.

      Delete
    17. ... generally true if the input (V in this case) is a superposition of step functions stepping only at sample times AKA a zero order hold (ZOH) function AKA a sample and hold function.

      Delete
    18. Roger, I took a look on my phone... So it's a little hard to tell but it looks like you raised the resistance values to order of 1 M ohm. The circuit rings now, but that's impossible with a first order circuit. What I suspect is happening is the simulation itself is breaking down. By default the time step it uses is 5 us, but with more than 1 Meg resistors and 1 H of inductance your time constant will be < 1/1e6 = 1 usec, and that's not going to give an accurate simulation. Try lowering your R values to order of 0.1 ohms and then increase the simulation time step by 1000 to 1 ms. That should give you a time constant on the order of a few seconds. Then adjust your simulation speed with the slider in the upper right corner so the rise fits within your scope like in my picture above (or try my sim again up with the link up at the top of the post... I probably adjusted it to look better since you last tried it).

      Delete
    19. The little "m"s next to my resistor values stands for "milli" not "Mega."

      Delete
    20. Roger, I edited your circuit to change the time constants to be on the order of several seconds, and to be consistent with the simulation's time step (which you had at 2 ms, which was fine... I may have changed it to 1 ms though... no biggie). Now you don't see the false artifact of a ringing circuit anymore.

      Look for my comment on your post dated April 16, 2016 at 4:09 PM. The one right below it gives the same thing, except with embedded scope labels.

      Here's a link to make it easier (on me!). One thing you may have noticed with blogger pages as opposed to posts: the links to specific comments don't work. One of the reasons I prefer to make a post rather than a page most of the time. So that's why I give the date and time of my comment instead: you can do a copy (here) and then there a CNTRL-F and a paste, and you'll zoom right there.

      Delete
  10. Tom, I put the new circuit into the page with notice that you had created it. Thanks. It works great.

    Your new circuit also works great, as does the link taking me there. The SPDT switch really helps the scope displays.

    On my page (your link works OK), I left a comment about going forward. Are you going to write a post to unify your solution? I write about completing my draft post and further goals.

    I'll probably take a day or two before editing the draft post. It will be a major rewrite! Lol

    ReplyDelete
    Replies
    1. Hi Roger, yes, I regret putting all this material on a page rather than a post. I could move it over, but then I'd lose the comments. Maybe I'll move it over and leave this here and provide a link back to this page.

      And yes, I have more to do. I will make a similar circuit with different values for the Cm and Dm matrices (the state space measurement matrices) to reflect instantaneous values of Y and T (which is more like what a real continuous time model would be doing behind the scenes, if you were integrating over a sliding window of length Ts to produce SIM outputs). Then I may even unify the two models to show how they're related.

      Also, I'd like to use and op amp based circuit to produce the full SIM model (with Y, T, YD and C measurements). It'll be much easier using op amps I think.

      Plus I still need to go back and correct the bottom half of my SIM8 and to simplify (this time I swear it will be simpler!) my SIM 9 plots.

      I left you a message on your page about Nick Rowe type models. Boy are you in luck because two years ago I did a whole post on that with an interactive Excel spreadsheet, and an extensive write up. ;)

      (and if you actually read it all the way through, you might be the 1st one to do so!) Lol.

      Delete
    2. "Nick Rowe type models" should be "Nick Edmonds type models"

      Delete
  11. Roger, I discovered one cool thing you can do is edit the voltage of the voltage source on the fly while the simulation is running. So for example you could drop it to 10 volts from 20 volts after some period of time. Similar to the facility you have in your SIM spreadsheet to allow something different to happen with G after 10 steps. But you can also change the voltage source to an entirely different kind, such as a square wave generator, with an offset if you like. See my figure 4 I added to the post. I provide a link there as well (this one). It's kind of fun to play with!

    I've seen in their circuit examples where they put voltage sources in series running at different frequencies to produce complex looking voltage waveforms (in summation).

    ReplyDelete
    Replies
    1. Roger, here's a version with op amps: it produces the whole SIM model, with scopes (unlabeled) across the bottom (left to right): G, H, Y, T, YD and C. Calculating the values for R and C (no L in this case) is MUCH easier. Basically I just take the values I have for A, B, Cm and Dm from my state space representation and either plug them (or their inverse) straight in. No complicated circuit analysis required. And the way it's laid out, it mimics the state space equations themselves.

      Delete
    2. The voltage source is on the right (with a switch nearby): G is the voltage just to the left of the switch. It's scope is on the far left on the bottom. then on the left side there are 5 outputs top to bottom in a column:

      H
      Y
      T
      YD
      C

      Their scopes are arranged left to right in that order, after G's scope. Do you see the one capacitor? That's were H is accumulated. The 4 bottom op amps of the 5 arranged in a column on the left are each a summing amplifier and they implement each row of the state space measurement equation $y = C_m x + D_m u$ where the subscript "m" denotes "measurement" to distinguish $C_m$ from SIM's output C. Each has two input resistors, which are set to the reciprocal of the corresponding elements in $D_m$ and $C_m$ matrices (see my SIM2 for the values). They each also have a feedback resistor (directly above each op amp) which is set to 1 ohm in all cases. The amplifier at the top in the middle (with a capacitor in its feedback path) is the integrating amplifier, and its top feedback resistor is set to $-1/a$ and its input resistor is set to $1/b$. Those are values are called "a_cont" and "b_cont" respectively in SIM2 (you have to scroll to the right to see their values) to distinguish them from the discrete time $A$ and $B$. The integrating op amp implements the state space state differential equation $\dot{x} = a x + b u$.

      The op amp on the top right (slightly under the integrating one) and the one on the top left (on the output of the integrating op amp) are both inverting op amps with a gain of -1. The integrating and summing op amps are inverting, which is why those two inverting op amps are required.

      Here are all the values (the reciprocal values in the last column):

      Name value 1/value
      A = 0.846153846 N/A (discrete time)
      B = 0.615384615 N/A (discrete time)
      a_cont = -0.167054085 -5.9860852970
      b_cont = 0.668216339 1.4965213242
      CY = 0.769230769 1.3000000000
      CT = 0.153846154 6.5000000000
      CYD = 0.615384615 1.6250000000
      CC = 0.769230769 1.3000000000
      DY = 1.923076923 0.5200000000
      DT = 0.384615385 2.6000000000
      DYD = 1.538461538 0.6500000000
      DC = 0.923076923 1.0833333333

      Delete
    3. If you want to learn more about using op amps to implement true continuous time state space equations, I found this rather dated short appendix online (it's only 10 pages (a pdf)), but it covers it pretty well. It's pretty straight-forward!

      Delete
    4. Wow, what have you done? !! I will look later this afternoon.

      Do you have my email? rsparks elltel.net

      Time to go to church.

      Delete
    5. Your op amp circuit is impressive. It demonstrates that all of the measures are related and they all have a growth and decay curve. I am impressed with the skill demonstrated in putting this together in such a short time.

      IMO, this demonstrates the wisdom of your suggesting a circuit for an economic model. It also demonstrates that what appears to be a good model for the economy (SFC) works for a circuit model.

      Congratulations!

      Delete
    6. I was thinking abut your use of the large capacitor to illustrate the durability of term H during rundown.

      Nick Rowe wrote a post on the durability of money. I picked up on that and wrote a followup post and gave the Durable Goods Model a name. Nick never followed up on the idea. I thought the concept led to some interesting conclusions. The idea of the private economy as a money storage goes right along with that model.

      My post is here The Durable Goods Model and Debt

      I was wondering how to model money and and slowly realized that money is the most durable good of all. It does not disappear unless it is made to disappear as in taxation. Nick and others may disagree with that claim.

      Your model will run until turned off. The economy is somewhat the same IMO.

      I delayed working on the Durable Goods Model when we started hard on the SIM modeling. I thought SIM was an opportunity best followed. Glad that I did follow.

      Delete
    7. Hi Roger, thanks. I remember that post of Nick's, but I didn't follow it too well (I just skimmed it really). I recall seeing John Handley (probably the brightest 15-year old I've encountered online ... or anywhere else) was digging into it as well in the comments. I'll check out your post.

      Delete
    8. Hi Roger, here's the basic shape of what the RC dual of my basic RL ciruit looks like, except that I don't have the parameters (values of C and R) filled in correctly yet. Recall, all the replacements I made to create a dual to the above circuit. I think everything required is there. Instead of currently I'm concerned with voltages this time (aside from the source: the 20 amp current supply is now my G). Voltage across the capacitor and the resistor in parallel with it ($R_1$) is now my H. $R_2$ is now in series with them (below in the diagram) and $R_{3_1}$ and $R_{3_2}$ are stacked in series with each other on the far right.

      Delete
    9. However the values for all the R come from similar formulas, but are not quite the same. Also C's values is not just a copy of L's value (I don't think). I haven't settled on all the values yet. What I have are expressions for $a$ and $b$ given that I know the values, and those expressions are similar to the ones for the RL circuit we did previously.

      Delete
    10. ... also, in terms of drawing a simple circuit like that, using the shortcuts it becomes quite easy: w for wires, r for resistors, and c for capacitors. Once you get the hang of it, you can throw something like that together in a jiffy. The only piece I had to go to the menu for was the current source and the SPDT switch (such a switch is required in a circuit with a current source because you can't just leave a current source open circuited). ... and now checked, I see that a SPDT switch also has a shortcut (S).

      Delete
    11. We know from the continuous time version of SIM that $a \approx -0.16$ and $b \approx 0.67$. For the RC circuit above we have (taking $R_3 = R_{3_1} + R_{3_2}$):
      $$a = -\frac{1}{C} \frac{R_1 + R_2 + R_3}{R_1 (R_2 + R_3)} \tag {1a}$$
      $$b = \frac{1}{C} \frac{R_3}{R_2 + R_3} \tag {1b}$$

      Delete
    12. I like your capacitor as the storage device. The curve stays the same but now the current continues in the same direction during rundown.

      Here is a switched circuit where you can manually add in a second voltage source to give a second step as the first step approaches stability.

      http://www.falstad.com/circuit/circuitjs.html?cct=$+1+0.001+4.621633621589249+33+5+50%0AS+400+240+400+192+0+0+false+0%0Aw+320+192+320+432+0%0Aw+416+192+576+192+0%0Aw+576+192+576+224+0%0Ar+576+224+576+304+0+0.1%0Ac+672+224+672+304+0+10+9.329263898739359e-11%0Aw+576+192+672+192+0%0Aw+672+224+672+192+0%0Aw+576+304+624+304+0%0Aw+624+304+672+304+0%0Aw+624+320+624+304+0%0Ar+624+320+624+384+0+0.1%0Aw+624+384+624+432+0%0Aw+672+192+768+192+0%0Aw+768+192+768+224+0%0Aw+624+432+768+432+0%0Aw+768+432+768+400+0%0Ar+768+224+768+304+0+0.1%0Aw+768+304+768+320+0%0Ar+768+320+768+400+0+0.1%0Aw+400+272+400+240+0%0Aw+448+336+416+336+0%0Aw+384+432+320+432+0%0Aw+384+432+384+352+0%0Aw+384+352+384+336+0%0Aw+448+432+448+384+0%0Aw+448+432+384+432+0%0Aw+448+432+624+432+0%0Av+448+384+448+336+0+0+40+5+0+0+0.5%0Av+400+304+400+272+0+0+40+5+0+0+0.5%0AS+400+304+400+336+0+1+false+0%0Ao+5+64+0+34+5+25.6+0+-1%0A

      Delete
    13. Nice!... the result looks very much like one of your diagrams I notice. You could do it with a current source too by making your own: since some transistors are essentially voltage controlled current sources, right? I'd have to look up with ones exactly (it's been a while). They have what seems to me to be a good selection of different semiconductor models in the library.

      Delete
  12. Hi Tom,

    I put up a new web page at

    http://mechanicalmoney.blogspot.com/p/finding-sims-alpha1-in-usa-economy.html

    We have talked a little about the SIM term $ \alpha1 $ . I decided to see if I could tease it out of the flow of funds data. I got to thinking that it must be the difference between government taxes and spending. If that is correct, then the chart shown on the page is what $ \alpha1 $ looks like over the years.

    It is fun to translate theory to actual results. Am I doing it correctly?

    ReplyDelete