Of Solve Blocks and a Sound Mind

Solve block

**Guest post by Luke Westbrook**

No one wants to spend weeks, months, or, heaven forbid, years working on a product, only to discover during prototype testing a fatal flaw in the design. At that point, the amount of money, labor, resources, and mental exertion spent on the project is extensive, and going back to the drawing board, even if only for a tiny rod or spring or circuit connection, can be annoyingly or even disastrously costly.

This is, of course, the reason behind performing simulations of systems, components, events, what have you. Simulations cannot take the place of data gathered in real-world testing, but in those situations, which are numerous, where real-world testing is costly or, as in some more theoretical applications, impossible, simulations are not merely convenient; they are necessary.

But even simulations can be cumbersome. Having to rewrite code and re-execute scripts, or needing to scour spreadsheet cells to determine where changes need to be made to cell references, all the while hoping that you didn’t miss anything—all of this is tiresome and error-prone. So it’s not enough to just be able to do the calculations needed for simulation; you need to be able to change parameters, adjust equations, and alter inputs fluidly and simply.

PTC Mathcad enables you to do just that. With natural math notation and live math regions that automatically update when changes are made, experimenting with simulation parameters and analyzing the outcomes of those simulations is fast and almost error-proof. And with Solve Blocks, this becomes even easier.

You probably know by now that Solve Blocks are a great way to perform a great number of different calculations, not the least of which being solving systems of equations and ordinary differential equations (ODEs). But sometimes it’s not enough to be able to find solutions; you need to be able to see how those solutions are affected by varying certain parameters. And this, my friends, is where things get pretty cool.

Let’s imagine, to start, a very basic situation in which you have a simplesolve block circuit (see figure right), and, given the resistances and voltages, you need to calculate the current through each branch of the circuit. So you start with your Guess Values, type out the constraints, which in this case is a system of linear equations, and insert your find function. Easy.

solve blockBut now I want to experiment with this simulation by seeing how the value of the 8-Ω resistor affects the circuit’s behavior. I could, of course, just go back into the solve block and change all the eights to twos or fours or whatever, but this is cumbersome if I need to do this multiple times. Plus, I don’t just want to test a few. I want to test an entire range of resistor values and see the behavior of the circuit. Not a problem. All I have to do now is replace the 8 Ω values with a variable, say R1, and then parameterize the result of the find function. This gives me a three-element vector, with each element, corresponding to the three currents, being its own function of R1. I can then plot each current against whatever range I choose for R1 and determine my desired resistor value based on how I want the circuit to behave.

solve block

Again, it’s a simple example, but the value here is clear. But let’s take things up a notch. Systems of equations are one-thing, but how would I parameterize an ODE problem? To answer that question, I have a mass attached to a spring and a damper.

This time I have a mass attached to a spring and a damper. I set up the given values, the motion equation, and the initial conditions, and then finish off with the odesolve function, allowing me to generate a plot of this one situation.

solve block

But now I want to know how the mass determines the system behavior. Again, I could just change the given value of the mass and watch how the plot changes, but I want to see the traces on the same plot in order to compare apples to apples. So I delete the definition of the variable m, and instead assign the odesolve function to a function of m. I can now assign this function with different mass values to individual functions and plot all of them together on the same graph.

solve block

 

Hopefully with these two examples of parameterizing your Solve Blocks, you will be able to better take advantage of PTC Mathcad’s solving capabilities, thereby reducing errors in design and saving you and your company time, money, and frustration.

Test it out for yourself; download the free systems of equations worksheet and PTC Mathcad Express today.

 

Quick Links

PTC Mathcad Express

Free for life version

PTC Mathcad Features

90 second videos

Resources

Training, live demos, free worksheets

This entry was posted in Mathcad, Tips & Tricks, Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s