Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Jun 5, 2012, 10:12 a.m. EDT
Hi,
Yes it is possible.
All models generated in COMSOL can be transferred to MATLAB, be it coefficient form or others. Of course you go to matlab provided you want to do things that cannot be easily or efficiently implemented within COMSOL GUI.
I think (but I cannot guarantee as I don't know your work) it is not difficult for you to solve equations with time dependent coefficients. This can be done explicitly in MATLAB by storing previous time step values in an array and calling them in subsequent time steps. This is one approach.
It can also be done in COMSOL GUI itself if you choose to work with "time discrete solver" wherein you have prev(u,i) operator from which you can use previous time step values in the current time step (u is any expression that is a function of time). This is available in the manual. There is also '"at" and "with" operators, which you can read yourself from the manual. There are also many threads that tell you how to do this exactly.
May be there are other ways too.
Hope this helps.
Suresh
Hi,
Yes it is possible.
All models generated in COMSOL can be transferred to MATLAB, be it coefficient form or others. Of course you go to matlab provided you want to do things that cannot be easily or efficiently implemented within COMSOL GUI.
I think (but I cannot guarantee as I don't know your work) it is not difficult for you to solve equations with time dependent coefficients. This can be done explicitly in MATLAB by storing previous time step values in an array and calling them in subsequent time steps. This is one approach.
It can also be done in COMSOL GUI itself if you choose to work with "time discrete solver" wherein you have prev(u,i) operator from which you can use previous time step values in the current time step (u is any expression that is a function of time). This is available in the manual. There is also '"at" and "with" operators, which you can read yourself from the manual. There are also many threads that tell you how to do this exactly.
May be there are other ways too.
Hope this helps.
Suresh
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Jun 6, 2012, 4:11 a.m. EDT
Hi,
Thank you for your answer !
Hi,
Yes it is possible.
All models generated in COMSOL can be transferred to MATLAB, be it coefficient form or others. Of course you go to matlab provided you want to do things that cannot be easily or efficiently implemented within COMSOL GUI.
I think (but I cannot guarantee as I don't know your work) it is not difficult for you to solve equations with time dependent coefficients. This can be done explicitly in MATLAB by storing previous time step values in an array and calling them in subsequent time steps. This is one approach.
It sound quite messy. I'm still wondering if instead of setting constant values to the coefficient, we could instead set a time-dependant function. Something similar to pdepe, somehow.
www.mathworks.fr/help/techdoc/ref/pdepe.html
It can also be done in COMSOL GUI itself if you choose to work with "time discrete solver" wherein you have prev(u,i) operator from which you can use previous time step values in the current time step (u is any expression that is a function of time). This is available in the manual. There is also '"at" and "with" operators, which you can read yourself from the manual. There are also many threads that tell you how to do this exactly.
Sounds great. Which manual are you talking about ? Been searching for it yesterday and haven't found precisely, which one, you were talking about... The API Guide ?
May be there are other ways too.
Hope this helps.
Suresh
Matt
Hi,
Thank you for your answer !
[QUOTE]
Hi,
Yes it is possible.
All models generated in COMSOL can be transferred to MATLAB, be it coefficient form or others. Of course you go to matlab provided you want to do things that cannot be easily or efficiently implemented within COMSOL GUI.
I think (but I cannot guarantee as I don't know your work) it is not difficult for you to solve equations with time dependent coefficients. This can be done explicitly in MATLAB by storing previous time step values in an array and calling them in subsequent time steps. This is one approach.
[/QUOTE]
It sound quite messy. I'm still wondering if instead of setting constant values to the coefficient, we could instead set a time-dependant function. Something similar to pdepe, somehow.
http://www.mathworks.fr/help/techdoc/ref/pdepe.html
[QUOTE]
It can also be done in COMSOL GUI itself if you choose to work with "time discrete solver" wherein you have prev(u,i) operator from which you can use previous time step values in the current time step (u is any expression that is a function of time). This is available in the manual. There is also '"at" and "with" operators, which you can read yourself from the manual. There are also many threads that tell you how to do this exactly.
[/QUOTE]
Sounds great. Which manual are you talking about ? Been searching for it yesterday and haven't found precisely, which one, you were talking about... The API Guide ?
[QUOTE]
May be there are other ways too.
Hope this helps.
Suresh
[/QUOTE]
Matt
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Jun 6, 2012, 5:38 a.m. EDT
Hi,
In COMSOL GUI, under help, just type prev() and you will get to know. Because everything in the manual can also be accessed through the GUI help, at least that is what I realise.
Also please download a file that Niklas Rom (from COMSOL) had uploaded into this discussion forum in response to a query concerning time discrete solver.
Suresh
Hi,
In COMSOL GUI, under help, just type prev() and you will get to know. Because everything in the manual can also be accessed through the GUI help, at least that is what I realise.
Also please download a file that Niklas Rom (from COMSOL) had uploaded into this discussion forum in response to a query concerning time discrete solver.
Suresh
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Jun 6, 2012, 5:41 a.m. EDT
Thanks a lot for your help, sir.
Have a nice day,
Matt
Thanks a lot for your help, sir.
Have a nice day,
Matt
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
Jun 29, 2012, 9:15 a.m. EDT
Hello again,
I am stuck again, when it comes down to defining time/space-dependant coefficients in livelink...
Basically, I would like to define a coefficient which will depend on time and space variables in the coefficient form PDE case.
Space and time have been "meshed" into a grid like this. I haven't encountered any issue with the grid.
t_set = [0:0.02:1];
x_set = [0:0.02:1];
y_set = [0:0.02:1];
At this point I need to define a function fun1, which basically returns a coefficient in a 3D-Matrix m_(x,y,t) whose size is length(t_set) * length(x_set) * length(y_set).
This m_ matrix does not depend on the differential equation to be solved. We assume, it is known at the beginning.
out = fun1(t,x,y)
t_num = find(t_set>t,1);
if isempty(t_num)
t_num = length(t_set);
end
x_num = find(x_set>x,1);
if isempty(t_num)
x_num = length(x_set);
end
y_num = find(y_set>y,1);
if isempty(y_num)
y_num = length(y_set);
end
out = m_(x_num, y_num, t_num)
end
Basically, I would like to do this kind of thing.
model.physics('c').feature('cfeq1').set('a', 1, 'fun1(t,x,y)');
But it does not work... I've been reading the manual about the at(), with() and prev() operators as advised by Suresh, but I don't see how it could help me on this. I simply don't get it.
Any simple illustrative example ? Any lead that could help me on this ?
Thank you for your time.
Hello again,
I am stuck again, when it comes down to defining time/space-dependant coefficients in livelink...
Basically, I would like to define a coefficient which will depend on time and space variables in the coefficient form PDE case.
Space and time have been "meshed" into a grid like this. I haven't encountered any issue with the grid.
[QUOTE]
t_set = [0:0.02:1];
x_set = [0:0.02:1];
y_set = [0:0.02:1];
[/QUOTE]
At this point I need to define a function fun1, which basically returns a coefficient in a 3D-Matrix m_(x,y,t) whose size is length(t_set) * length(x_set) * length(y_set).
This m_ matrix does not depend on the differential equation to be solved. We assume, it is known at the beginning.
[QUOTE]
out = fun1(t,x,y)
t_num = find(t_set>t,1);
if isempty(t_num)
t_num = length(t_set);
end
x_num = find(x_set>x,1);
if isempty(t_num)
x_num = length(x_set);
end
y_num = find(y_set>y,1);
if isempty(y_num)
y_num = length(y_set);
end
out = m_(x_num, y_num, t_num)
end
[/QUOTE]
Basically, I would like to do this kind of thing.
[QUOTE]
model.physics('c').feature('cfeq1').set('a', 1, 'fun1(t,x,y)');
[/QUOTE]
But it does not work... I've been reading the manual about the at(), with() and prev() operators as advised by Suresh, but I don't see how it could help me on this. I simply don't get it.
Any simple illustrative example ? Any lead that could help me on this ?
Thank you for your time.