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.

unknown variable after creating it in an analytical function

Please login with a confirmed email address before reporting spam

Hello,

I have created two variables 't' and 's' using analytic functions namely an1 & an2 respectively. while the first variable 't' seems to be recognised fine , it is the other variable 's' which doesnt seem to be recognised. The expression which has both 't' and 's' shows in orange in comsol . Upon hovering my mouse pointer on this expression i get " unknown variable 's' ". Please help me with this. Been terribly stuck for very long.

I have attached the snapshots of the issue i am facing. I have also attached the mph file ( cleared all solutions to reduce file size).

Thanks, Ashish



3 Replies Last Post Jan 8, 2024, 2:49 a.m. EST
Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 11 months ago Jan 2, 2024, 9:59 a.m. EST

Hi Ashish,

The arguments in the analytic functions are internal to them, used to define the function as a function of one or more variables. When calling the analytic function, you must do so with a variable that is defined in the model. In your case, you can call both an1 and an2 with t, for example, which is the predefined variable for time in your model. On the other hand, s is not known outside of an2 (but s1 and s2 would be, as surface parameterizations in 3D, for example; s is predefined as an edge parameterization in 2D).

Best regards,

Magnus

Hi Ashish, The arguments in the analytic functions are internal to them, used to define the function as a function of one or more variables. When calling the analytic function, you must do so with a variable that is defined in the model. In your case, you can call both `an1` and `an2` with `t`, for example, which is the predefined variable for time in your model. On the other hand, `s` is not known outside of `an2` (but `s1` and `s2` would be, as surface parameterizations in 3D, for example; `s` is predefined as an edge parameterization in 2D). Best regards, Magnus

Please login with a confirmed email address before reporting spam

Posted: 11 months ago Jan 5, 2024, 9:58 a.m. EST

Dear Magnus,

Thanks for writing back to me.

However, my issue is little different. In the 'variables' section you should find an variable called 'A'

where, A=(exp(-5.724e-10an2(s)) - 1.0)(0.5/(0.00025an2(s) + 1.0) - 0.5/(0.00025an1(t) + 1.0))^2(1.891e+5an1(t) - 3.782e+8(2.0/(0.00025an1(t) + 1.0) + (0.00025an1(t) + 1.0)^2)(0.00025an1(t) + 1.0)(8.333e-5an1(t) + 0.3333) + 7.564e+8) + (exp(-5.724e-10an2(s)) - 1.0)(0.5/(0.00025an2(s) + 1.0) - 0.5/(0.00025an1(t) + 1.0))^2(1.891e+5an1(t) - 3.782e+8(2.0/(0.00025an1(t) + 1.0) + (0.00025an1(t) + 1.0)^2)((0.00025an1(t) + 1.0)^2 + (0.00025an1(t) + 1.0)(8.333e-5an1(t) + 0.3333)) + 7.564e+8) + (exp(-5.724e-10an2(s)) - 1.0)(0.5/(0.00025an2(s) + 1.0) - 0.5/(0.00025an1(t) + 1.0))(0.5(0.00025an2(s) + 1.0)^2 - 0.5(0.00025an1(t) + 1.0)^2)(94550.0an1(t) + 6.051e+15/(an1(t) + 4000.0)^2 - (2.017e+15(2.0/(0.00025an1(t) + 1.0) + (0.00025an1(t) + 1.0)^2)(0.00025*an1(t) + 1.0))/(an1(t) + 4000.0)^2 + 3.782e+8)

where 't' varies from 0 to 1000 seconds( 1000 seconds is the total simulation time period). The time step (lets say dt) is 1 second. 's' on the other hand is a smaller time step which varies within the confinements of each time step. In other words, when t=1 second , s varies from 0 to 1. when t=2 second , s varies from 1 to 2. when t=3 second , s varies from 2 to 3. .. . . . when t=800 second , s varies from 799 to 800. .. . . when t=1000 second , s varies from 999 to 1000.

To acheive this i used two analytic functions "an1(t)" and "an2(s)" . But the expression for A(shown above) shows orange . This is because 'an2(s)' is not recognised. ( I am pretty sure an1(t) only seems to be recognised as perhaps Comsol perceives it to be time , which is right by the way).

Please help me with this, coz as i said earlier i am terribly stuck with this.

P.S: You may refer to the image and mph files shared earlier in this conversation thread.

Thanks, Ashish

Dear Magnus, Thanks for writing back to me. However, my issue is little different. In the 'variables' section you should find an variable called 'A' where, A=(exp(-5.724e-10*an2(s)) - 1.0)*(0.5/(0.00025*an2(s) + 1.0) - 0.5/(0.00025*an1(t) + 1.0))^2*(1.891e+5*an1(t) - 3.782e+8*(2.0/(0.00025*an1(t) + 1.0) + (0.00025*an1(t) + 1.0)^2)*(0.00025*an1(t) + 1.0)*(8.333e-5*an1(t) + 0.3333) + 7.564e+8) + (exp(-5.724e-10*an2(s)) - 1.0)*(0.5/(0.00025*an2(s) + 1.0) - 0.5/(0.00025*an1(t) + 1.0))^2*(1.891e+5*an1(t) - 3.782e+8*(2.0/(0.00025*an1(t) + 1.0) + (0.00025*an1(t) + 1.0)^2)*((0.00025*an1(t) + 1.0)^2 + (0.00025*an1(t) + 1.0)*(8.333e-5*an1(t) + 0.3333)) + 7.564e+8) + (exp(-5.724e-10*an2(s)) - 1.0)*(0.5/(0.00025*an2(s) + 1.0) - 0.5/(0.00025*an1(t) + 1.0))*(0.5*(0.00025*an2(s) + 1.0)^2 - 0.5*(0.00025*an1(t) + 1.0)^2)*(94550.0*an1(t) + 6.051e+15/(an1(t) + 4000.0)^2 - (2.017e+15*(2.0/(0.00025*an1(t) + 1.0) + (0.00025*an1(t) + 1.0)^2)*(0.00025*an1(t) + 1.0))/(an1(t) + 4000.0)^2 + 3.782e+8) where 't' varies from 0 to 1000 seconds( 1000 seconds is the total simulation time period). The time step (lets say dt) is 1 second. 's' on the other hand is a smaller time step which varies within the confinements of each time step. In other words, when t=1 second , s varies from 0 to 1. when t=2 second , s varies from 1 to 2. when t=3 second , s varies from 2 to 3. .. . . . when t=800 second , s varies from 799 to 800. .. . . when t=1000 second , s varies from 999 to 1000. To acheive this i used two analytic functions "an1(t)" and "an2(s)" . But the expression for A(shown above) shows orange . This is because 'an2(s)' is not recognised. ( I am pretty sure an1(t) only seems to be recognised as perhaps Comsol perceives it to be time , which is right by the way). Please help me with this, coz as i said earlier i am terribly stuck with this. P.S: You may refer to the image and mph files shared earlier in this conversation thread. Thanks, Ashish

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 11 months ago Jan 8, 2024, 2:49 a.m. EST

Hi Ashish,

It is not clear to me what you want to achieve here. The only time variable that the COMSOL Multiphysics software recongnizes is t, and the time steps for a transient simulation are determined by the solver (but there are many settings that you can use to control the time stepping). The output times (the times for which a solution is computed and stored for further processing) are specified by the user in the Time Dependent (or similar) study step. If you have further questions, I recommend that you contact COMSOL Support: https://www.comsol.com/support/case/.

Best regards, Magnus

Hi Ashish, It is not clear to me what you want to achieve here. The only time variable that the COMSOL Multiphysics software recongnizes is `t`, and the time steps for a transient simulation are determined by the solver (but there are many settings that you can use to control the time stepping). The output times (the times for which a solution is computed and stored for further processing) are specified by the user in the **Time Dependent** (or similar) study step. If you have further questions, I recommend that you contact COMSOL Support: . Best regards, Magnus

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.