thegrumpys / odop

Open Design Optimization Platform (ODOP) - Coil spring design app; mechanical springs; compression spring, extension spring, torsion spring
https://www.springdesignsoftware.org
MIT License
4 stars 5 forks source link

Script tutor4p10 - unexpected disable of FS_2 MIN #737

Closed grumpyinca closed 2 years ago

grumpyinca commented 2 years ago

A mystery: Disabling of the FS_2 MIN constraint as the compression spring script tutor4 transitions from page 9 to page 10 is unexpected. While I am working in and observing the problem in branch 729, I also observe the same behavior in v4.2.2 production.

I suspect that this could be a script programming error. It most likely involves lines 341-343 of branch 729 compression/tutor4.js:

                saveOutputSymbolConstraints('FS_2'),
                setSymbolFlag('FS_2', MAX, CONSTRAINED),
                changeSymbolConstraint('FS_2', MAX, 1.75),

To replicate the problem:

  1. In branch 729, reload the ODOP:Spring app
  2. Help : Tutorial : tutor4
  3. Advance to page 9
  4. Observe that the MIN constraint on FS_2 is enabled (This is expected behavior)
  5. Next (to page 10)
  6. Observe that the MIN constraint on FS_2 is disabled (This is unexpected behavior - why?)
1fifoto commented 2 years ago

The saveOutputSymbolConstraints function does the following:

                        lmin: 0,
                        oldlmin: element.lmin,
                        oldcmin: element.cmin,
                        lmax: 0,
                        oldlmax: element.lmax,
                        oldcmax: element.cmax

In other words, by saving the output symbol constraints it resets both the MIN and the MAX CONSTRAINT flags located in lmin and lmax. The saveOutputSymbolConstraints and restoreOutputSymbolConstraints work as a pair and are useful when FIXing and FREEing independent or dependent variables which have constraints.

Bottom line, I don't think you should be doing any saveOutputSymbolConstraints calls if your macros are not expecting to do any restoreOutputSymbolConstraints calls.

So the function is working as designed.

grumpyinca commented 2 years ago

I will use branch 729 to change the script programming per the recommendation above. Closing this issue with no other code changes.