Can I use Sympy to deduce the telegraphers equation?
I was trying to deduce the Telegrapher's equation using SymPy. But I couldn't handle nor extract the equation's different parts, so I finally did it manually. Can this be done using SymPy ? I've tried to use subs
but I didn't achieve good results.
Thanx in advance! The following code was my attempt to solve the problem:
from sympy import *
# init_printing(use_unicode=True, wrap_line=False)
V, I = symbols('V I', cls=Function)
z = Symbol('z')
t = Symbol('t')
R, L, C, G = symbols('R L C G', positive=True)
eq1 = Derivative(V(z, t),z, 1) + R * I(z, t)+L* Derivative(I(z,t),t,1)
# Derivative(V(z, t), z) + L*Derivative(I(z, t), t) + R*I(z, t)
eq2 = Derivative(I(z,t),z,1)+G*V(z,t)+C*Derivative(V(z,t),t,1)
# Derivative(I(z, t), z) + C*Derivative(V(z, t), t) + G*V(z, t)
eq3 = eq1.diff(z,1)
#eq3 = L*Derivative(I(z, t), t, z) + R*Derivative(I(z, t), z) + Derivative(V(z, t), z, z)
eq4 = eq2.diff(z,1)
#eq4 = C*Derivative(V(z, t), t, z) + G*Derivative(V(z, t), z) + Derivative(I(z, t), z, z)
# Then part of eq1 is replaced in eq4
# (-1*(R*I(z,t)+L*I(z,t).diff(t,1)))
eq5 = C*Derivative(V(z, t), t, z) + G*(-1* (R*I(z,t)+L*I(z,t).diff(t,1))) + Derivative(I(z, t), z, z)
# And similarly for eq2 in eq3
# (-1*(G*V(z,t)+C*V(z,t).diff(t,1)))
eq6 = L*Derivative(I(z, t), t, z) + R*(-1* (G*V(z,t)+C*V(z,t).diff(t,1))) + Derivative(V(z, t), z, z)
# the derivative in time of eq1
eq7 = eq1.diff(t,1)
# eq7 = L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t) + Derivative(V(z, t), t, z)
# Derivative(V(z, t), t, z) = -1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t))
# the derivative in time of eq2
eq8 = eq2.diff(t,1)
# eq8 = C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t) + Derivative(I(z, t), t, z)
# Derivative(I(z, t), t, z) = -1* (C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t))
# Replace eq 7 in eq5
Telegraphers_eq1 = C*-1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t)) + G*(-L*Derivative(I(z, t), t) - R*I(z, t)) + Derivative(I(z, t), z, z)
# Replace eq 8 in eq6
Telegraphers_eq2 = L*-1*(C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t)) + R*(-C*Derivative(V(z, t), t) - G*V(z, t)) + Derivative(V(z, t), z, z)
cheers,
Pedro
python sympy cas equation differential-equations
add a comment |
I was trying to deduce the Telegrapher's equation using SymPy. But I couldn't handle nor extract the equation's different parts, so I finally did it manually. Can this be done using SymPy ? I've tried to use subs
but I didn't achieve good results.
Thanx in advance! The following code was my attempt to solve the problem:
from sympy import *
# init_printing(use_unicode=True, wrap_line=False)
V, I = symbols('V I', cls=Function)
z = Symbol('z')
t = Symbol('t')
R, L, C, G = symbols('R L C G', positive=True)
eq1 = Derivative(V(z, t),z, 1) + R * I(z, t)+L* Derivative(I(z,t),t,1)
# Derivative(V(z, t), z) + L*Derivative(I(z, t), t) + R*I(z, t)
eq2 = Derivative(I(z,t),z,1)+G*V(z,t)+C*Derivative(V(z,t),t,1)
# Derivative(I(z, t), z) + C*Derivative(V(z, t), t) + G*V(z, t)
eq3 = eq1.diff(z,1)
#eq3 = L*Derivative(I(z, t), t, z) + R*Derivative(I(z, t), z) + Derivative(V(z, t), z, z)
eq4 = eq2.diff(z,1)
#eq4 = C*Derivative(V(z, t), t, z) + G*Derivative(V(z, t), z) + Derivative(I(z, t), z, z)
# Then part of eq1 is replaced in eq4
# (-1*(R*I(z,t)+L*I(z,t).diff(t,1)))
eq5 = C*Derivative(V(z, t), t, z) + G*(-1* (R*I(z,t)+L*I(z,t).diff(t,1))) + Derivative(I(z, t), z, z)
# And similarly for eq2 in eq3
# (-1*(G*V(z,t)+C*V(z,t).diff(t,1)))
eq6 = L*Derivative(I(z, t), t, z) + R*(-1* (G*V(z,t)+C*V(z,t).diff(t,1))) + Derivative(V(z, t), z, z)
# the derivative in time of eq1
eq7 = eq1.diff(t,1)
# eq7 = L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t) + Derivative(V(z, t), t, z)
# Derivative(V(z, t), t, z) = -1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t))
# the derivative in time of eq2
eq8 = eq2.diff(t,1)
# eq8 = C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t) + Derivative(I(z, t), t, z)
# Derivative(I(z, t), t, z) = -1* (C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t))
# Replace eq 7 in eq5
Telegraphers_eq1 = C*-1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t)) + G*(-L*Derivative(I(z, t), t) - R*I(z, t)) + Derivative(I(z, t), z, z)
# Replace eq 8 in eq6
Telegraphers_eq2 = L*-1*(C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t)) + R*(-C*Derivative(V(z, t), t) - G*V(z, t)) + Derivative(V(z, t), z, z)
cheers,
Pedro
python sympy cas equation differential-equations
add a comment |
I was trying to deduce the Telegrapher's equation using SymPy. But I couldn't handle nor extract the equation's different parts, so I finally did it manually. Can this be done using SymPy ? I've tried to use subs
but I didn't achieve good results.
Thanx in advance! The following code was my attempt to solve the problem:
from sympy import *
# init_printing(use_unicode=True, wrap_line=False)
V, I = symbols('V I', cls=Function)
z = Symbol('z')
t = Symbol('t')
R, L, C, G = symbols('R L C G', positive=True)
eq1 = Derivative(V(z, t),z, 1) + R * I(z, t)+L* Derivative(I(z,t),t,1)
# Derivative(V(z, t), z) + L*Derivative(I(z, t), t) + R*I(z, t)
eq2 = Derivative(I(z,t),z,1)+G*V(z,t)+C*Derivative(V(z,t),t,1)
# Derivative(I(z, t), z) + C*Derivative(V(z, t), t) + G*V(z, t)
eq3 = eq1.diff(z,1)
#eq3 = L*Derivative(I(z, t), t, z) + R*Derivative(I(z, t), z) + Derivative(V(z, t), z, z)
eq4 = eq2.diff(z,1)
#eq4 = C*Derivative(V(z, t), t, z) + G*Derivative(V(z, t), z) + Derivative(I(z, t), z, z)
# Then part of eq1 is replaced in eq4
# (-1*(R*I(z,t)+L*I(z,t).diff(t,1)))
eq5 = C*Derivative(V(z, t), t, z) + G*(-1* (R*I(z,t)+L*I(z,t).diff(t,1))) + Derivative(I(z, t), z, z)
# And similarly for eq2 in eq3
# (-1*(G*V(z,t)+C*V(z,t).diff(t,1)))
eq6 = L*Derivative(I(z, t), t, z) + R*(-1* (G*V(z,t)+C*V(z,t).diff(t,1))) + Derivative(V(z, t), z, z)
# the derivative in time of eq1
eq7 = eq1.diff(t,1)
# eq7 = L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t) + Derivative(V(z, t), t, z)
# Derivative(V(z, t), t, z) = -1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t))
# the derivative in time of eq2
eq8 = eq2.diff(t,1)
# eq8 = C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t) + Derivative(I(z, t), t, z)
# Derivative(I(z, t), t, z) = -1* (C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t))
# Replace eq 7 in eq5
Telegraphers_eq1 = C*-1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t)) + G*(-L*Derivative(I(z, t), t) - R*I(z, t)) + Derivative(I(z, t), z, z)
# Replace eq 8 in eq6
Telegraphers_eq2 = L*-1*(C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t)) + R*(-C*Derivative(V(z, t), t) - G*V(z, t)) + Derivative(V(z, t), z, z)
cheers,
Pedro
python sympy cas equation differential-equations
I was trying to deduce the Telegrapher's equation using SymPy. But I couldn't handle nor extract the equation's different parts, so I finally did it manually. Can this be done using SymPy ? I've tried to use subs
but I didn't achieve good results.
Thanx in advance! The following code was my attempt to solve the problem:
from sympy import *
# init_printing(use_unicode=True, wrap_line=False)
V, I = symbols('V I', cls=Function)
z = Symbol('z')
t = Symbol('t')
R, L, C, G = symbols('R L C G', positive=True)
eq1 = Derivative(V(z, t),z, 1) + R * I(z, t)+L* Derivative(I(z,t),t,1)
# Derivative(V(z, t), z) + L*Derivative(I(z, t), t) + R*I(z, t)
eq2 = Derivative(I(z,t),z,1)+G*V(z,t)+C*Derivative(V(z,t),t,1)
# Derivative(I(z, t), z) + C*Derivative(V(z, t), t) + G*V(z, t)
eq3 = eq1.diff(z,1)
#eq3 = L*Derivative(I(z, t), t, z) + R*Derivative(I(z, t), z) + Derivative(V(z, t), z, z)
eq4 = eq2.diff(z,1)
#eq4 = C*Derivative(V(z, t), t, z) + G*Derivative(V(z, t), z) + Derivative(I(z, t), z, z)
# Then part of eq1 is replaced in eq4
# (-1*(R*I(z,t)+L*I(z,t).diff(t,1)))
eq5 = C*Derivative(V(z, t), t, z) + G*(-1* (R*I(z,t)+L*I(z,t).diff(t,1))) + Derivative(I(z, t), z, z)
# And similarly for eq2 in eq3
# (-1*(G*V(z,t)+C*V(z,t).diff(t,1)))
eq6 = L*Derivative(I(z, t), t, z) + R*(-1* (G*V(z,t)+C*V(z,t).diff(t,1))) + Derivative(V(z, t), z, z)
# the derivative in time of eq1
eq7 = eq1.diff(t,1)
# eq7 = L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t) + Derivative(V(z, t), t, z)
# Derivative(V(z, t), t, z) = -1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t))
# the derivative in time of eq2
eq8 = eq2.diff(t,1)
# eq8 = C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t) + Derivative(I(z, t), t, z)
# Derivative(I(z, t), t, z) = -1* (C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t))
# Replace eq 7 in eq5
Telegraphers_eq1 = C*-1*(L*Derivative(I(z, t), t, t) + R*Derivative(I(z, t), t)) + G*(-L*Derivative(I(z, t), t) - R*I(z, t)) + Derivative(I(z, t), z, z)
# Replace eq 8 in eq6
Telegraphers_eq2 = L*-1*(C*Derivative(V(z, t), t, t) + G*Derivative(V(z, t), t)) + R*(-C*Derivative(V(z, t), t) - G*V(z, t)) + Derivative(V(z, t), z, z)
cheers,
Pedro
python sympy cas equation differential-equations
python sympy cas equation differential-equations
edited Nov 22 at 19:11
asked Nov 21 at 20:43
Pedro S.
65
65
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420192%2fcan-i-use-sympy-to-deduce-the-telegraphers-equation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420192%2fcan-i-use-sympy-to-deduce-the-telegraphers-equation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown