Robert Koslover
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
8 months ago
Mar 26, 2024, 11:52 a.m. EDT
Updated:
8 months ago
Mar 26, 2024, 11:52 a.m. EDT
I think this information from the Help system, about using setind and/or setval with withsol might work for you:
"setind and setval
setind and setval can only be used within withsol or withparam. The following text explains the syntax using withsol, but it is the same for withparam.
Use setind to specify a parameter index and setval to specify a parameter value in connection with the withsol operator (see withsol). For parametric sweeps over several parameters, say p and q, setval and setind can be used in any combination for the two parameters — for example, withsol('sol1',expr,setind(p,2,q,3)) or withsol('sol1',expr,setind(p,2),setval(q,5)).
Negative indices in setind are counted from the end. For example, in a time-dependent solver, withsol('sol1',expr,setind(t,-2)) evaluates expr at the second last time step. An alternative notation for the first and last indices is setind(p,'first') and setind(p,'last').
You can use setind and setval with more than two arguments to make the syntax more compact. For example, withsol('sol1',expr,setval(p,1,q,2)) is equivalent to withsol('sol1',expr,setval(p,1),setval(q,2))."
-------------------
Scientific Applications & Research Associates (SARA) Inc.
www.comsol.com/partners-consultants/certified-consultants/sara
I think this information from the Help system, about using *setind* and/or *setval* with *withsol* might work for you:
"setind and setval
setind and setval can only be used within withsol or withparam. The following text explains the syntax using withsol, but it is the same for withparam.
Use setind to specify a parameter index and setval to specify a parameter value in connection with the withsol operator (see withsol). For parametric sweeps over several parameters, say p and q, setval and setind can be used in any combination for the two parameters — for example, withsol('sol1',expr,setind(p,2,q,3)) or withsol('sol1',expr,setind(p,2),setval(q,5)).
Negative indices in setind are counted from the end. For example, in a time-dependent solver, withsol('sol1',expr,setind(t,-2)) evaluates expr at the second last time step. An alternative notation for the first and last indices is setind(p,'first') and setind(p,'last').
You can use setind and setval with more than two arguments to make the syntax more compact. For example, withsol('sol1',expr,setval(p,1,q,2)) is equivalent to withsol('sol1',expr,setval(p,1),setval(q,2))."
Please login with a confirmed email address before reporting spam
Posted:
8 months ago
Mar 26, 2024, 12:22 p.m. EDT
Thanks for the reply!
I had already seen these functions (setind and setval) but from what I understood, as you also reported, they allow you to define the withsol function only at certain moments of time or for certain values.
For example withsol('sol1',expr,setind(p,2)) refers to the second time instant, right?
What I would like to do is something like ('sol1',expr,setind(p,All_timestep)) where the values of p at each time step are taken into consideration.
Is it possible to do this and how should I write the withsol function?
Thanks for the reply!
I had already seen these functions (setind and setval) but from what I understood, as you also reported, they allow you to define the withsol function only at certain moments of time or for certain values.
For example withsol('sol1',expr,setind(p,2)) refers to the second time instant, right?
What I would like to do is something like ('sol1',expr,setind(p,All_timestep)) where the values of p at each time step are taken into consideration.
Is it possible to do this and how should I write the withsol function?
Robert Koslover
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
8 months ago
Mar 26, 2024, 1:05 p.m. EDT
Updated:
8 months ago
Mar 26, 2024, 1:12 p.m. EDT
Ah. If neither setind or setval work satisfactorily in this context, you may need to set up some kind of separate interpolation operation. (Note: According to the Help system, the use of setval in the withsol operation will support interpolation.) But I'm not sure if you might be having some kind of time-variable-naming issue. In principle, you could export the results (for J vs, time) of one run and then import those results into an interpolation function to use with your boundary condition in a subsequent run, but I suspect a less cumbersome approach exists. Perhaps another user, or Comsol employee, can suggest a more elegant solution?
-------------------
Scientific Applications & Research Associates (SARA) Inc.
www.comsol.com/partners-consultants/certified-consultants/sara
Ah. If neither *setind* or *setval* work satisfactorily in this context, you may need to set up some kind of separate interpolation operation. (Note: According to the Help system, the use of *setval* in the *withsol* operation will support interpolation.) But I'm not sure if you might be having some kind of time-variable-naming issue. In principle, you could export the results (for J vs, time) of one run and then import those results into an interpolation function to use with your boundary condition in a subsequent run, but I suspect a less cumbersome approach exists. Perhaps another user, or Comsol employee, can suggest a more elegant solution?