Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Functional Solve Block

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

08-24-2017
07:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
07:42 AM

Functional Solve Block

Hi

I was trying to develop a function to calculate flow depth in D-shaped Tunnel. My attached sheet calculates correctly for First Tunnel section. However for second tunnel, It is giving wrong result. In fact it is not changing parrments of tunnel, which I intend to.

please have a look at attached version 14 File.

Thanks in Advance

A. Prasun.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

08-24-2017
01:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
01:05 PM

Here you are.

As I wrote in my first answer, the problem was, that your calculations did not use the new values for B, H, etc. which you provided as function arguments and that you have to use those arguments as function arguments of Q (and all functions called by Q) as well.

Doing those changes now you get the 1.14 m you expected.

I have deleted the argument H as it is never used in the relevant calculations!

You also never use the functions "full" and "full_d", but if you intend to do so in the future, H should be an additional function argument.

In the pic I have underlined the changes made. The green underlined change of the name of the variable of integration is not mandatory, it will work with alpha, too. But from a mathematical point of view the variable of integration and the limit should never be the same name, especially as the limit is a function with the name alpha.

10 REPLIES 10

08-24-2017
08:41 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
08:41 AM

It would be better if you posted the worksheet (you have to zip it first). Based on the pdf, I suspect the problem is the guess value. Get rid of the guess value y1:=1m before the solve block, and add y1 as an argument to the depth function. Then you can try different guess values further down the worksheet by changing the last parameter in the function call.

08-24-2017
10:57 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
11:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
11:15 AM

Given your math, the solve block is returning the correct answer:

08-24-2017
12:42 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
12:42 PM

Actually it is giving answer for tunnel of bigger size ; for B=H= 8.5 m and not for B=H= 6 m.

the answer remains same even if I modify the values of B h or slope.

08-24-2017
01:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
01:05 PM

Here you are.

As I wrote in my first answer, the problem was, that your calculations did not use the new values for B, H, etc. which you provided as function arguments and that you have to use those arguments as function arguments of Q (and all functions called by Q) as well.

Doing those changes now you get the 1.14 m you expected.

I have deleted the argument H as it is never used in the relevant calculations!

You also never use the functions "full" and "full_d", but if you intend to do so in the future, H should be an additional function argument.

In the pic I have underlined the changes made. The green underlined change of the name of the variable of integration is not mandatory, it will work with alpha, too. But from a mathematical point of view the variable of integration and the limit should never be the same name, especially as the limit is a function with the name alpha.

08-25-2017
12:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-25-2017
12:24 AM

Thanks werner...

@WernerExinger wrote:

Here you are.

As I wrote in my first answer, the problem was, that your calculations did not use the new values for B, H, etc. which you provided as function arguments and that you have to use those arguments as function arguments of Q (and all functions called by Q) as well.

Doing those changes now you get the 1.14 m you expected.

I have deleted the argument H as it is never used in the relevant calculations!

You also never use the functions "full" and "full_d", but if you intend to do so in the future, H should be an additional function argument.

In the pic I have underlined the changes made. The green underlined change of the name of the variable of integration is not mandatory, it will work with alpha, too. But from a mathematical point of view the variable of integration and the limit should never be the same name, especially as the limit is a function with the name alpha.

08-25-2017
12:36 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-25-2017
12:36 AM

A a next level of problem, I want to send following inputs from Excel into Mathcad

(a) B,H,r, Vertical --> Parameters of Tunnel

(b) Discharge, Q

(c) bed slope

Mathcad will calculate the Depth of Flow and

Then I want to Pull the output of mathcad into Excel.

Here I will keep excel in Front and Mathcad will do the calculation in the back ground and send data back to Excel in a cell.

can you suggest some ways, how to integrate this using Mathcad 14 and Excel .

Thanks once again in advance.

A. Prasun

08-25-2017
03:46 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-25-2017
03:46 AM

Calling Mathcad from within Excel can be tricky and I never have seen any need to do so myself.

In the help (-> developers reference) you find some informations about Mathcad automation interfaces and links to some examples

You can also make a search here in the froum for something like "call Mathcad from Excel" and see, if the threads are of any help.

08-24-2017
10:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
10:15 AM

As Richard already said - its better if you attach the worksheet itself and not just a static picture or pdf.

One things I noticed ist that your function depth(..) has 6 arguments but none of the first five arguments are used! All your calculations use just the values of B,H, etc. which are defined at the top of your sheet. The only argument which really influences the calculations is the last argument "dis".

This may be the reason for the wrong result as you provide differnet values for B, H, etc when you call the function the second time, but the function still uses the values defined at the top.

You would have to make Q a function with all those arguments, too!

08-24-2017
11:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-24-2017
11:07 AM

I tried inserting y1 or guess value of flow depth in function but still same issue. wrong answer.

The function is not working if i modify the variables ( change the size or slope of tunnel).