Calculation Time

Calculation Time - How can I reduce the time it takes to recalculate - Сообщения

#1 Опубликовано: 10.11.2017 17:13:58
subseapark

subseapark

0 сообщений из 9 понравились пользователям.

Группа: User

In the attached file I've calculated the frequency response of an electronic filter and plotted the result. The calculation time however is excessive, and takes anywhere from 30s to a minute to implement. This has made the calculation process (i.e. development and debugging) an agonisingly slow experience.

As I'm still learning the ins-and-outs of SMath, I'm curious to know if there is anything I've done (which could be done differently) that is causing the excessive recalculation time? And if so, what would be a more efficient method to implement the calculation be?

As a comparison, on implementing the same calculation in MathCAD 14, the re-calculation time was almost instantaneous.

Process time.jpg

SMath file: Filter Response.sm (96 КиБ) скачан 46 раз(а).
MathCAD file: Filter Response.xmcd (127 КиБ) скачан 30 раз(а).
#2 Опубликовано: 10.11.2017 18:16:00
Arie

Arie

93 сообщений из 285 понравились пользователям.

Группа: User

I changed all of your assignments optimizations from Symbolic to Numeric.

It originally ran at 5.45 seconds on my machine. Now runs in 0.849 seconds. Filter Response_optimized.sm (96 КиБ) скачан 36 раз(а).

You can right click on an assignment and there will be a menu for optimizations. You can choose symbolic, numeric or none.

I'm not exactly sure if what I'm about to say is true, but it is how I interpret those settings.

For what you are doing, when you assign a value to Z.d for example, you want the expression to be evaluated and assigned to Z.d. That is what numerical optimization does, I believe. You could also envelope everything in the eval() statement, but I think it does the same thing.

When the optimization is set to symbolic, the expression isn't evaluated right away. Instead it points to assignment and re-evaluates it whenever Z.d is called. So if you use Z.d multiple times it re-evaluates it every time. When you have multiple expressions that are symbolic and repeated you can see how this could stack up and cause some delay. The program might be evaluating Z.d 20 times, rather than just one.

Again, I don't know if I explained it right. I don't fully understand it myself. But I tend to have the feeling that numerical optimization evaluates the expression immediately while symbolic optimization will evaluate the expression whenever is it called later on.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
1 пользователям понравился этот пост
subseapark 10.11.2017 18:59:00
#3 Опубликовано: 10.11.2017 18:35:00
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

And if so, what would be a more efficient method to implement the calculation be?

Comments:
1. "i" from the palette is buit-in imaginary [though nothing wrong SQRT(-1)
2. once the you have evaluated results.... My Equation = you can disable
all local evaluations, they are in the "cryogenic register"
3. All the vectorized functions eval(,)

Something to review about the magenta/orange traces ... Maybe units ?


Timing dropped down from 45 sec down 7 !!!

Cheers Houston ...

Filter Response_1.sm (100 КиБ) скачан 64 раз(а).

1 пользователям понравился этот пост
subseapark 10.11.2017 18:59:00
#4 Опубликовано: 10.11.2017 19:07:56
subseapark

subseapark

0 сообщений из 9 понравились пользователям.

Группа: User

I took Jean's file and changed all the assignment to Numeric; as suggested by alyles. This dropped the recalculation time a further 20%.

MAGNIFICENT

Thank you both!
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений