Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.
Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
Heavyside-Function and Divison by Zero
Posted Feb 11, 2013, 2:13 p.m. EST RF & Microwave Engineering, Parameters, Variables, & Functions Version 4.3a 2 Replies
Please login with a confirmed email address before reporting spam
Hi
I stumble realising a Gaussian-beam like in the tutorial model "Nanorods" (using RF-module).
Problem:
Part of the wave function has a singularity: constant/z
Solution in tutorial:
Define a piecewise-function covering the singularity like:
z<-z0 : constant/z
-z0<z<z0 : constant/z0
z0<z : constant/z
But in contrary to the example I need frequency-dependent borders respectively frequency-dependent z0 [Z0(freq)].
As this is not possible with piecewise-function (i guess) i tried a sum of Haevyside-functions (like recommended in several forum-posts):
(constant/z)*flc2hs(-z-Z0(freq),range)
+(constant/z0)*flc2hs(z+Z0(freq),range)*flc2hs(-z+Z0(freq),range)
+(constant/z)*flc2hs(z-Z0(freq),range)
Does the same when being plotted from the Global_Definition/Anayltics-Node. Produces also no error when the model is being computed. But trying to plot from Solution1-Node producing the error:
Evaluation of result expression failed
Error in user-defined function
Failed to evaluate expression
This error does not occur if the (constant/z)-function is replaced by a non-singularity-function. So plotting after computing messes somehow with the Heavyside-function.
Any idea or experience how to get that work? This starts to erode my self-confidence.
Thanks for any help
edit: Problem was, i think, not the above expression but the fact that inside of the wave-function something gets divided by that expression. And i think the smoothening of the heavyside-function leads to a zero at the singularity. And then again divided by zero ^.^ -> error
Though i am not sure.
But in this case using the inverse function just works fine : )
I stumble realising a Gaussian-beam like in the tutorial model "Nanorods" (using RF-module).
Problem:
Part of the wave function has a singularity: constant/z
Solution in tutorial:
Define a piecewise-function covering the singularity like:
z<-z0 : constant/z
-z0<z<z0 : constant/z0
z0<z : constant/z
But in contrary to the example I need frequency-dependent borders respectively frequency-dependent z0 [Z0(freq)].
As this is not possible with piecewise-function (i guess) i tried a sum of Haevyside-functions (like recommended in several forum-posts):
(constant/z)*flc2hs(-z-Z0(freq),range)
+(constant/z0)*flc2hs(z+Z0(freq),range)*flc2hs(-z+Z0(freq),range)
+(constant/z)*flc2hs(z-Z0(freq),range)
Does the same when being plotted from the Global_Definition/Anayltics-Node. Produces also no error when the model is being computed. But trying to plot from Solution1-Node producing the error:
Evaluation of result expression failed
Error in user-defined function
Failed to evaluate expression
This error does not occur if the (constant/z)-function is replaced by a non-singularity-function. So plotting after computing messes somehow with the Heavyside-function.
Any idea or experience how to get that work? This starts to erode my self-confidence.
Thanks for any help
edit: Problem was, i think, not the above expression but the fact that inside of the wave-function something gets divided by that expression. And i think the smoothening of the heavyside-function leads to a zero at the singularity. And then again divided by zero ^.^ -> error
Though i am not sure.
But in this case using the inverse function just works fine : )
2 Replies Last Post Feb 12, 2013, 12:09 p.m. EST