Skip to main content
1-Visitor
September 29, 2017
Solved

Error in while loop

  • September 29, 2017
  • 4 replies
  • 2878 views

I'm currently trying to write a while loop that will loop and add 1 cm to (D.section1) until the loop is able to reduce the total Incident Energy to under 1.1 but currently I'm getting a statement saying "This function refers to itself inconsistently"

Best answer by MJG

Looking further up in your sheet, I assume you mean Incident Energy should be cal/cm^2 - not cal/J.

Here is the corrected program per my previous three notes:

Capture.PNG

Yellow highlights indicate my additions.  Red arrows indicate removal of the unnecessary unit conversions.  You were essensially multiplying by 1 (that's what Valery was showing).

4 replies

24-Ruby IV
September 29, 2017

Sorry

What is it

Jcal.png

1-Visitor
September 29, 2017

Good catch, Valery. I just saw the unit inconsisency. It looks like OP is trying to manage their own units. Let Mathcad do that work!

1-Visitor
September 29, 2017

The error message is not very helpful, but here are some findings:

  • IE.Temp is not defined before the while loop.  It must be defined in order for Mathcad to know if it should enter the loop or not.
  • IE.Temp has units, but you are comparing it to a unitless quantity (1.1).  Your comparison must be unit consistent.  Is it 1.1*kg/s^2 ?
  • AFB.1 is initially defined with unit length.  Within the while loop you add 1 to AFB.1.  Should this be AFB.1 + 1cm?
1-Visitor
September 29, 2017

The goal is to be able to find the working distance from where the Incident Energy which is measured in (cal/J) is lower than or equal 1.1 this defines a boundary in which I need. IE.Temp1 calculates the initial incident energy while IE.Temp2 determines the backfeed incident energy.

MJG1-VisitorAnswer
1-Visitor
September 29, 2017

Looking further up in your sheet, I assume you mean Incident Energy should be cal/cm^2 - not cal/J.

Here is the corrected program per my previous three notes:

Capture.PNG

Yellow highlights indicate my additions.  Red arrows indicate removal of the unnecessary unit conversions.  You were essensially multiplying by 1 (that's what Valery was showing).

1-Visitor
September 29, 2017

Wow thank you so much! You guys are great!

21-Topaz II
September 29, 2017

loop corretto.jpg