That's great news. I will include the direct method in my notes as well. -- This message may contain unintentional errors, as it was typed on a phone
> On 23 Feb 2016, at 22:47, Aaron Meurer <asmeu...@gmail.com> wrote: > > In master I get the solution > > In [46]: sympy.solve(eq.coeffs(), [K_C, tau_I, tau_D]) > Out[46]: > ⎡ ⎧ -(τ₁ + τ₂) τ₁⋅τ₂ ⎫⎤ > ⎢{K_C: 0, τ_I: 0}, ⎨K_C: ───────────, τ_D: ───────, τ_I: τ₁ + τ₂⎬⎥ > ⎣ ⎩ K⋅(φ - τ_c) τ₁ + τ₂ ⎭⎦ > > It looks like whatever fixed it will be included in 1.0 (it's also > fixed in the 1.0 release branch). > > Aaron Meurer > >> On Tue, Feb 23, 2016 at 12:43 AM, Carl Sandrock <carl.sandr...@gmail.com> >> wrote: >> I am attempting to work a problem from a textbook in sympy, but sympy fails >> to find a solution which appears valid. For interest, it is the design of a >> PID controller using direct synthesis with a second order plus dead time >> model. >> >> The whole problem can be reduced to finding K_C, tau_I and tau_D which will >> make >> >> K_C*(s**2*tau_D*tau_I + s*tau_I + 1)/(s*tau_I) = (s**2*tau_1*tau_2 + s*tau_1 >> + s*tau_2 + 1)/(K*s*(-phi + tau_c)) >> >> >> for given tau_1, tau_2, K and phi. >> >> >> I have tried to solve this by matching coefficients: >> >> >> import sympy >> >> >> s, tau_c, tau_1, tau_2, phi, K = sympy.symbols('s, tau_c, tau_1, tau_2, phi, >> K') >> >> target = (s**2*tau_1*tau_2 + s*tau_1 + s*tau_2 + 1)/(K*s*(-phi + tau_c)) >> >> K_C, tau_I, tau_D = sympy.symbols('K_C, tau_I, tau_D', real=True) >> PID = K_C*(1 + 1/(tau_I*s) + tau_D*s) >> >> eq = (target - PID).together() >> eq *= sympy.denom(eq).simplify() >> eq = sympy.poly(eq, s) >> >> sympy.solve(eq.coeffs(), [K_C, tau_I, tau_D]) >> >> This returns an empty matrix. However, the textbook provides the following >> solution: >> >> booksolution = {K_C: 1/K*(tau_1 + tau_2)/(tau_c - phi), >> tau_I: tau_1 + tau_2,a >> tau_D: tau_1*tau_2/(tau_1 + tau_2)} >> >> Which appears to satisfy the equations I'm trying to solve: >> >> [c.subs(booksolution).simplify() for c in eq.coeffs()] >> >> returns >> >> [0, 0, 0] >> >> Can I massage this into a form which sympy can solve? What am I doing wong? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sympy+unsubscr...@googlegroups.com. >> To post to this group, send email to sympy@googlegroups.com. >> Visit this group at https://groups.google.com/group/sympy. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/4d922cfe-9f54-4196-b7d8-15abb053e091%40googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to a topic in the Google > Groups "sympy" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/sympy/JJVkM7Cs9MA/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > sympy+unsubscr...@googlegroups.com. > To post to this group, send email to sympy@googlegroups.com. > Visit this group at https://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2B1HHFtcfF5XBzKDEAR3KAyE1L42CymgM8LreOKnyNz%3DA%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CF288D1A-0DB5-40F4-9057-D48EC9BA93D1%40gmail.com. For more options, visit https://groups.google.com/d/optout.