hammer

9 Reputation

2 Badges

18 years, 258 days

MaplePrimes Activity


These are replies submitted by hammer

Thanks one more time. I began to use solve, but it isn't clear to me why is it better (or which are the differences between them). About the second issue, I chose the second alternative; but both of them are clear to me (or so I think). Now I have a clean solution. Despite it seems that solve doesn't use assume, I continued to use them because I saw (quite reasonably to me) that the results of simplify depend on them. About the text manipulation, I'll do it by hand in a text editor, as you said. After all, I only have to wrap 20 lines approximately and do some replacements. Besides that, I don´t find the wrapText function, maybe it's provided in newer versions. A thing that I don't know why is happening is that all the parameters of the generated procedures get renamed as cgX (X a number), and I get a warning: "The following variable name replacements were made...". But it's irrelevant. Thanks again.
Thanks one more time. I began to use solve, but it isn't clear to me why is it better (or which are the differences between them). About the second issue, I chose the second alternative; but both of them are clear to me (or so I think). Now I have a clean solution. Despite it seems that solve doesn't use assume, I continued to use them because I saw (quite reasonably to me) that the results of simplify depend on them. About the text manipulation, I'll do it by hand in a text editor, as you said. After all, I only have to wrap 20 lines approximately and do some replacements. Besides that, I don´t find the wrapText function, maybe it's provided in newer versions. A thing that I don't know why is happening is that all the parameters of the generated procedures get renamed as cgX (X a number), and I get a warning: "The following variable name replacements were made...". But it's irrelevant. Thanks again.
Thank you very much for your guidance. With your tips I managed to find more information about what I was looking for. Despite the progress, I haven´t yet tested the solutions with good parameters and compared them with real data. Here's my code. I'm sure you will have some sugestions about it. The system is the inductance coupling of three RLC circuits (one of them harmonically driven). One problem that I couldn't figure out how to deal properly is the handling of the result of "solveFor". That function returns, I think, a set (unordered) of solutions: the order of solI1, solI2 and solI3 varies from time to time. So when I execute the command "op(1,sol)" I don't know which solution I'll get: in order to have the variables with proper names I have to look the current order and, if the first unknown appears first in the result, write accordingly solI1Mod := simplify(abs(rhs(op(1,sol)))); Another drawback was that the VisualBasic code is generated for .NET whereas I want to work with VBA (visual Basic for Applications) in Excel Macros. What I've done is to "touch" a little bit the generated code (not a too good idea!): sqrt changed for sqr, the return statement was replaced with an assignament to a pseudo-variable with the name of the function, etc.. Also, despite the work done, some lines result long enough to break the VBA text-editor: I modified them inserting "_" at the end of each part of them (to continue the expression en the following line). > with(codegen,optimize,makeproc): > with(CodeGeneration): > assume( varE0 > 0 ); > assume( varM12 > 0 ); > assume( varM23 > 0 ); > assume( varM13 > 0 ); > assume( varW > 0 ); > assume( varR1 > 0 ); > assume( varR2 > 0 ); > assume( varR3 > 0 ); > assume( varX1, RealRange( -infinity, infinity )); > assume( varX2, RealRange( -infinity, infinity )); > assume( varX3, RealRange( -infinity, infinity )); > sol := solvefor[solI1,solI2,solI3](varE0 = solI1 * (varR1 + I * varX1) - I * varW * varM12 * solI2 - I * varW * varM13 * solI3, 0 = solI2 * (varR2 + I * varX2) - I * varW * varM12 * solI1 - I * varW * varM23 * solI3, 0 = solI3 * (varR3 + I * varX3) - I * varW * varM13 * solI1 - I * varW * varM23 * solI2 ); > solI1Mod := simplify(abs(rhs(op(1,sol)))); > solI1Proc := optimize(makeproc(solI1Mod,[varE0,varM12,varM23,varM13,varW,varR1,varR2,varR3,varX1,varX2,varX3])); > VisualBasic(solI1Proc,declare=[varE0::float,varM12::float,varM23::float,varM13::float,varW::float,varR1::float,varR2::float,varR3::float,varX1::float,varX2::float,varX3::float]); // The same 3 last things, for the other two solutions.
Thank you very much for your guidance. With your tips I managed to find more information about what I was looking for. Despite the progress, I haven´t yet tested the solutions with good parameters and compared them with real data. Here's my code. I'm sure you will have some sugestions about it. The system is the inductance coupling of three RLC circuits (one of them harmonically driven). One problem that I couldn't figure out how to deal properly is the handling of the result of "solveFor". That function returns, I think, a set (unordered) of solutions: the order of solI1, solI2 and solI3 varies from time to time. So when I execute the command "op(1,sol)" I don't know which solution I'll get: in order to have the variables with proper names I have to look the current order and, if the first unknown appears first in the result, write accordingly solI1Mod := simplify(abs(rhs(op(1,sol)))); Another drawback was that the VisualBasic code is generated for .NET whereas I want to work with VBA (visual Basic for Applications) in Excel Macros. What I've done is to "touch" a little bit the generated code (not a too good idea!): sqrt changed for sqr, the return statement was replaced with an assignament to a pseudo-variable with the name of the function, etc.. Also, despite the work done, some lines result long enough to break the VBA text-editor: I modified them inserting "_" at the end of each part of them (to continue the expression en the following line). > with(codegen,optimize,makeproc): > with(CodeGeneration): > assume( varE0 > 0 ); > assume( varM12 > 0 ); > assume( varM23 > 0 ); > assume( varM13 > 0 ); > assume( varW > 0 ); > assume( varR1 > 0 ); > assume( varR2 > 0 ); > assume( varR3 > 0 ); > assume( varX1, RealRange( -infinity, infinity )); > assume( varX2, RealRange( -infinity, infinity )); > assume( varX3, RealRange( -infinity, infinity )); > sol := solvefor[solI1,solI2,solI3](varE0 = solI1 * (varR1 + I * varX1) - I * varW * varM12 * solI2 - I * varW * varM13 * solI3, 0 = solI2 * (varR2 + I * varX2) - I * varW * varM12 * solI1 - I * varW * varM23 * solI3, 0 = solI3 * (varR3 + I * varX3) - I * varW * varM13 * solI1 - I * varW * varM23 * solI2 ); > solI1Mod := simplify(abs(rhs(op(1,sol)))); > solI1Proc := optimize(makeproc(solI1Mod,[varE0,varM12,varM23,varM13,varW,varR1,varR2,varR3,varX1,varX2,varX3])); > VisualBasic(solI1Proc,declare=[varE0::float,varM12::float,varM23::float,varM13::float,varW::float,varR1::float,varR2::float,varR3::float,varX1::float,varX2::float,varX3::float]); // The same 3 last things, for the other two solutions.
Page 1 of 1