Modeling a Time Varying Electrical Stimulation

Please login with a confirmed email address before reporting spam

Hi everyone,

I'm working on building a model that simulates a confined space with a custom, arbitrary time-varying waveform applied from an electrode. I'm looking for advice or examples from anyone who has experience using a time-varying interpolated waveform as an electrode voltage in COMSOL.

Any guidance or references to similar models would be greatly appreciated.

Thank you in advance for your help!


3 Replies Last Post 2024年8月26日 GMT+2 20:48
Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 week ago 2024年8月20日 GMT+2 11:58

Hi,

you can import a table defining the waveform into an interpolation function and use the function in the form f(t) for the electrode potential. There may be other options that suit your application better.

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi, you can import a table defining the waveform into an interpolation function and use the function in the form f(t) for the electrode potential. There may be other options that suit your application better. Cheers Edgar

Please login with a confirmed email address before reporting spam

Posted: 4 days ago 2024年8月26日 GMT+2 16:05
Updated: 4 days ago 2024年8月26日 GMT+2 16:10

Hi Edgar,

Thank you in advance for any assistance you can provide. I apologize for the delay in following up on this issue.

I’m currently working on a simulation where I need to apply a time-dependent current waveform to a terminal using an interpolated function. The waveform data was initially created in MATLAB, and I’m using LiveLink for MATLAB to integrate this with COMSOL.

Issue Description In the COMSOL GUI:

I attempted to apply an interpolated function based on data that includes local extrema (e.g., peaks and troughs in the waveform).However, I encountered errors such as "failed to converge" or "inconsistent value." These errors seem to arise specifically when the interpolation involves sharp changes or non-smooth transitions between these extrema.

Using LiveLink for MATLAB: When I tried to define and assign this interpolated function via LiveLink for MATLAB, I received an error indicating an "incorrect number or types of inputs" when attempting to set the interpolation table.I ensured that the data was formatted as a cell array with each row containing a time-current pair, but the error persists.

Questions:

Function Constraints: Are there any known constraints or best practices for applying interpolated functions to terminals or other boundary conditions in COMSOL, especially when the data includes sharp changes or local extrema? Could the convergence issues be related to the nature of the interpolation?

Data Formatting: Regarding the error in LiveLink for MATLAB, are there specific data formatting requirements or common pitfalls when assigning an interpolation table via LiveLink for MATLAB that I might have overlooked?

Any insights or suggestions on how to resolve these issues would be greatly appreciated. I’m particularly interested in understanding whether the convergence problems in the COMSOL GUI could be related to the mathematical properties of the interpolated function itself, and how best to format and apply such data through LiveLink for MATLAB.

Thank you again for your time and assistance.

Best, Sophia

Hi,

you can import a table defining the waveform into an interpolation function and use the function in the form f(t) for the electrode potential. There may be other options that suit your application better.

Cheers Edgar

Hi Edgar, Thank you in advance for any assistance you can provide. I apologize for the delay in following up on this issue. I’m currently working on a simulation where I need to apply a time-dependent current waveform to a terminal using an interpolated function. The waveform data was initially created in MATLAB, and I’m using LiveLink for MATLAB to integrate this with COMSOL. Issue Description In the COMSOL GUI: I attempted to apply an interpolated function based on data that includes local extrema (e.g., peaks and troughs in the waveform).However, I encountered errors such as "failed to converge" or "inconsistent value." These errors seem to arise specifically when the interpolation involves sharp changes or non-smooth transitions between these extrema. Using LiveLink for MATLAB: When I tried to define and assign this interpolated function via LiveLink for MATLAB, I received an error indicating an "incorrect number or types of inputs" when attempting to set the interpolation table.I ensured that the data was formatted as a cell array with each row containing a time-current pair, but the error persists. Questions: Function Constraints: Are there any known constraints or best practices for applying interpolated functions to terminals or other boundary conditions in COMSOL, especially when the data includes sharp changes or local extrema? Could the convergence issues be related to the nature of the interpolation? Data Formatting: Regarding the error in LiveLink for MATLAB, are there specific data formatting requirements or common pitfalls when assigning an interpolation table via LiveLink for MATLAB that I might have overlooked? Any insights or suggestions on how to resolve these issues would be greatly appreciated. I’m particularly interested in understanding whether the convergence problems in the COMSOL GUI could be related to the mathematical properties of the interpolated function itself, and how best to format and apply such data through LiveLink for MATLAB. Thank you again for your time and assistance. Best, Sophia >Hi, > >you can import a table defining the waveform into an interpolation function and use the function in the form f(t) for the electrode potential. >There may be other options that suit your application better. > >Cheers >Edgar

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 4 days ago 2024年8月26日 GMT+2 20:48

Hi Sophia,

I cannot give you advice regarding Matlab and the Livelink issues because I am not using it.

The time-dependent function needs to be sufficiently well behaved. Sharp peaks and discontinuities must be avoided. Spline and 3rd order polynomial interpolation is often doing a good job, but you should check any unfriendly parts of the function for proper interpolation. Maybe you need to add points to make the function more friendly and look differentiable.

You may also need to adjust the time dependent solver. The default suggested solver may not work properly. You may need to use manual time stepping and choose a time step that sufficiently samples the temporal behavior of the interpolation function. This is often a trial and error procedure. Refine the time stepping until the solver kicks off. In case the function isn't starting at zero for t = 0, you may need a stationary step before the time dependent step to provide a start point for the time dependent solver. Otherwise the solver sees a discontinuity from zero to the start value and may not be able to start iterating.

Maybe some other folks can help with the Matlab issues.

Good luck, Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Sophia, I cannot give you advice regarding Matlab and the Livelink issues because I am not using it. The time-dependent function needs to be sufficiently well behaved. Sharp peaks and discontinuities must be avoided. Spline and 3rd order polynomial interpolation is often doing a good job, but you should check any unfriendly parts of the function for proper interpolation. Maybe you need to add points to make the function more friendly and look differentiable. You may also need to adjust the time dependent solver. The default suggested solver may not work properly. You may need to use manual time stepping and choose a time step that sufficiently samples the temporal behavior of the interpolation function. This is often a trial and error procedure. Refine the time stepping until the solver kicks off. In case the function isn't starting at zero for t = 0, you may need a stationary step before the time dependent step to provide a start point for the time dependent solver. Otherwise the solver sees a discontinuity from zero to the start value and may not be able to start iterating. Maybe some other folks can help with the Matlab issues. Good luck, Edgar

Reply

Please read thediscussion forum rulesbefore posting.

Pleaselog into post a reply.

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

Baidu
map