Ivar KJELBERG
                                                                                                                                                    COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)
                                                         
                            
                         
                                                
    
        Please login with a confirmed email address before reporting spam
     
    
 
                                                Posted:
                            
                                1 decade ago                            
                            
                                2011年3月15日 GMT+8 23:32                            
                        
                        
                                                    Hi
Search for "state space" or "mphstate()"
By the way the doc is slightly misleading, here is a code that works for the doc (I received it from Remi of COMSOL support)
%%%%%%%%%%%%%%
 % Load the heat_convection_2d.mph model  
model = mphload('heat_convection_2d.mph');
 % Set the temperature condition with a constant parameter  
model.param.set('T0','373');  
model.physics('ht').feature('temp1').set('T0', 1, 'T0');  
% Add a point probe at [0.3;0.8]
pdom1 = model.probe.create('pdom1', 'DomainPoint');  
pdom1.model('mod1');  pdom1.setIndex('coords2','0.8',0,0);
pdom1.setIndex('coords2','0.3',0,0);
 % Extract matrix data
M = mphstate(model,'sol1','out',{'MA' 'MB' 'C' 'D'},...
 'input','T0', 'output', 'mod1.ppb1');
%%%%%%%%%%%%%%
At least this works OK for 4.1 ;)
--
Good luck
Ivar                                                
                                                
                            Hi
Search for "state space" or "mphstate()"
By the way the doc is slightly misleading, here is a code that works for the doc (I received it from Remi of COMSOL support)
%%%%%%%%%%%%%%
 % Load the heat_convection_2d.mph model  
model = mphload('heat_convection_2d.mph');
 % Set the temperature condition with a constant parameter  
model.param.set('T0','373');  
model.physics('ht').feature('temp1').set('T0', 1, 'T0');  
% Add a point probe at [0.3;0.8]
pdom1 = model.probe.create('pdom1', 'DomainPoint');  
pdom1.model('mod1');  pdom1.setIndex('coords2','0.8',0,0);
pdom1.setIndex('coords2','0.3',0,0);
 % Extract matrix data
M = mphstate(model,'sol1','out',{'MA' 'MB' 'C' 'D'},...
 'input','T0', 'output', 'mod1.ppb1');
%%%%%%%%%%%%%%
At least this works OK for 4.1 ;)
--
Good luck
Ivar                        
                                                
                                                                                                            
                                             
                                            
                                                
    
        Please login with a confirmed email address before reporting spam
     
    
 
                                                Posted:
                            
                                1 decade ago                            
                            
                                2011年4月2日 GMT+8 00:19                            
                        
                        
                                                    Hi Ivar,
Did you verify that the solution you get from using the state space matrices is the same as the solution you get from the COMSOL GUI?
V/R,
Andrew Wang                                                
                                                
                            Hi Ivar,
Did you verify that the solution you get from using the state space matrices is the same as the solution you get from the COMSOL GUI?
V/R,
Andrew Wang                        
                                                
                                                                                                            
                                             
                                            
                                                
    
        Please login with a confirmed email address before reporting spam
     
    
 
                                                Posted:
                            
                                1 decade ago                            
                            
                                2011年5月3日 GMT+8 23:02                            
                        
                        
                                                    Hi Andrew
I have not worked on it since last week -- I will hopefully get it done within a couple of days and then will let you know.
However, for the simple 2D heat-transfer problem (non-coupled, single physics problem), I believe it should give more or less the same results. But I will update once I have implemented it.
Madu                                                
                                                
                            Hi Andrew
I have not worked on it since last week -- I will hopefully get it done within a couple of days and then will let you know.
However, for the simple 2D heat-transfer problem (non-coupled, single physics problem), I believe it should give more or less the same results. But I will update once I have implemented it.
Madu                        
                                                
                                                                                                            
                                             
                                            
                                                
    
        Please login with a confirmed email address before reporting spam
     
    
 
                                                Posted:
                            
                                1 decade ago                            
                            
                                2011年5月7日 GMT+8 04:40                            
                        
                        
                                                    I worked this example in MATLAB (LiveLink), literally cutting and pasting from Ivar's example.  MATLAB throws no errors, but the 'C' matrix is empty which is something I would not expect considering the probe.  Also, I slightly modified the example by asking for the 'A' and 'B' matrices vice the 'MA' and 'MC' matrices.  In these cases, I get the following error:
??? Java exception occurred:
Exception:
	com.comsol.util.exceptions.FlException: Unknown property
Messages:
	Unknown property
	- Property: A
Does someone on this Forum know if there are some bugs in the code?  If so, has anyone heard when a fix is due out?
Thanks to all who take the time to answer this forum!   You are doing a great service to us 'new-to-COMSOL' folks.                                                
                                                
                            I worked this example in MATLAB (LiveLink), literally cutting and pasting from Ivar's example.  MATLAB throws no errors, but the 'C' matrix is empty which is something I would not expect considering the probe.  Also, I slightly modified the example by asking for the 'A' and 'B' matrices vice the 'MA' and 'MC' matrices.  In these cases, I get the following error:
??? Java exception occurred:
Exception:
	com.comsol.util.exceptions.FlException: Unknown property
Messages:
	Unknown property
	- Property: A
Does someone on this Forum know if there are some bugs in the code?  If so, has anyone heard when a fix is due out?
Thanks to all who take the time to answer this forum!   You are doing a great service to us 'new-to-COMSOL' folks.                        
                                                
                                                                                                            
                                             
                        
                        
                            
                                                                                        
                                Ivar KJELBERG
                                                                                                                                                    COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)
                                                         
                            
                         
                                                
    
        Please login with a confirmed email address before reporting spam
     
    
 
                                                Posted:
                            
                                1 decade ago                            
                            
                                2011年5月7日 GMT+8 18:48                            
                        
                        
                                                    Hi
I have not fully amnaged to get it eitherworkin under v4.1, so I'm waiting for 4.2. But there was another thread the last days, I believe using JAVA describing how to (or what is Matlab ?, I'm looking at to many threads here ;) 
oups it was the next thread in the list, here is the link
www.comsol.eu/community/forums/general/thread/13667/#p49298
--
Good luck
Ivar                                                
                            Hi
I have not fully amnaged to get it eitherworkin under v4.1, so I'm waiting for 4.2. But there was another thread the last days, I believe using JAVA describing how to (or what is Matlab ?, I'm looking at to many threads here ;) 
oups it was the next thread in the list, here is the link
http://www.comsol.eu/community/forums/general/thread/13667/#p49298
--
Good luck
Ivar