Skip to content

Commit

Permalink
Propose better unit-handling in equation.
Browse files Browse the repository at this point in the history
  • Loading branch information
HansOlsson committed Nov 2, 2022
1 parent f325ed3 commit 55070ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Modelica/Blocks/Sources.mo
Expand Up @@ -941,13 +941,14 @@ The Real output y is a trapezoid signal:
equation
y = if time < startTime then wMin else
if time < (startTime + max(duration,eps)) then
10^(log10(wMin) + (log10(wMax) - log10(wMin))*min(1, (time-startTime)/max(duration,eps)))
wMin * (wMax/wMin)^min(1, (time-startTime)/max(duration,eps))
else
wMax;
annotation (defaultComponentName="logSweep",
Documentation(info="<html>
<p>The output <code>y</code> performs a logarithmic frequency sweep.
The logarithm of frequency <code>w</code> performs a linear ramp from <code>log10(wMin)</code> to <code>log10(wMax)</code>.
It uses <code>wMin*(wMax/wMin)^x</code> instead of the equivalent <code>10^(log10(wMin)+log10(wMax)-log10(wMin)*x)</code> to help with unit-checking.
The output is the decimal power of this logarithmic ramp.
</p>
<p>For <code>time &lt; startTime</code> the output is equal to <code>wMin</code>.</p>
Expand Down

0 comments on commit 55070ff

Please sign in to comment.