Skip to content

Commit

Permalink
Merge pull request modelica#4055 from HansOlsson/LogSweepUnit
Browse files Browse the repository at this point in the history
Better unit-handling in equation for LogSweep
  • Loading branch information
casella committed Nov 15, 2022
2 parents e5aa74c + 55070ff commit 7b9cf4c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Modelica/Blocks/Sources.mo
Original file line number Diff line number Diff line change
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 7b9cf4c

Please sign in to comment.