Access Stiffness Matrix for each Parameter Sweep Value

Please login with a confirmed email address before reporting spam

Hi all,

I am trying to read stiffness matrix through Java. Currently, I am mostly following codes given in COMSOL Programming Reference Manual, which is: (1) create Assemble under my Solution 1 and (2) getSparseMatrixVal('K'), which gives me the global stiffness matrix.

This method works perfectly for Static problem, when I am using Stationary step with Stationary solver. However, if I include parametric sweep, I can only access to the stiffness matrix produced by the last parameter sweep.

For example: imagine a parameter p with values 1, 2, and 3. There is a Parametric attribute added under the Stationary Solver, which changes the parameter value through 1, 2 and 3. Let's assume, that Young's modulus depends on parameter p. Hence, the stiffness matrix of the element will change as the parameter p changes. However, I can only access the stiffness matrix for the last parameter p value, that is p = 3.

Does anyone know how can I access and read stiffness matrices for all of the parameter values? Unfortunately, I could not find any information in the manual.

Sincerely, Irakli


1 Reply Last Post 2024年3月15日 GMT+1 10:53
Remi Magnard COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 months ago 2024年3月15日 GMT+1 10:53
Updated: 5 months ago 2024年3月15日 GMT+1 13:34

Dear Irakli,

the Assemble feature uses the current solution as linearization point to assemble the system matrices and only the current assembled latest sysrtem matrices are store in the feature.

If you want to get the matrices for different parameters (and so different solutions) you need to create a second study, which uses the solution vector (from the first study) as initial value. In this second study place the Assemble feature just after the Variable feature ( You can find attached a demo model that shows how to proceed).

Then you only need to select which parameter to use (Step 1: Stationary>Values of Dependent Variables>Parameter value) and run the solver configuration up to the Assemble feature (useCompute to Selectedin the Assemble settings window). Finally extract the matrices component useing getSparseMatrixVal().

Dear Irakli, the Assemble feature uses the current solution as linearization point to assemble the system matrices and only the current assembled latest sysrtem matrices are store in the feature. If you want to get the matrices for different parameters (and so different solutions) you need to create a second study, which uses the solution vector (from the first study) as initial value. In this second study place the Assemble feature just after the Variable feature ( You can find attached a demo model that shows how to proceed). Then you only need to select which parameter to use (**Step 1: Stationary** > **Values of Dependent Variables** > **Parameter value** ) and run the solver configuration up to the Assemble feature (use **Compute to Selected** in the Assemble settings window). Finally extract the matrices component useing getSparseMatrixVal().

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