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.

how to use Prev(.) function during simulation? How to write FOR loop in comsol for simulation?

Krishnayan Bhattacharyya

Please login with a confirmed email address before reporting spam

Hi, Can you please help me out in using prev function to get back the dependent variables from last time step and use those in current timestep during simulation? in simply words how to make comsol work in For loop for certain dependent variables. my problem: theta(1)=0; for i=2:t { xA=c1-bsin(theta(i-1)); yA=c2+bcos(theta(i-1)); m=2(c1yA+c2xA); n=2(c1yA-c2xA); q=2xA^2+2yA^2+c1^2+c2^2-b^2; W=arccos(m/sqrt(m^2+n^2)); theta(i)=arccos(q/sqrt(m^2+n^2))-W; } end

How to write this FOR loop code in comsol? or is there any other ways to do the same task?


1 Reply Last Post Sep 20, 2020, 6:55 a.m. EDT
Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 4 years ago Sep 20, 2020, 6:55 a.m. EDT

Check this blog contribution: https://www.comsol.de/blogs/using-the-previous-solution-operator-in-transient-modeling/

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Check this blog contribution: https://www.comsol.de/blogs/using-the-previous-solution-operator-in-transient-modeling/ Cheers Edgar

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.