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.
External materials node - which variables are accessible to external wrapper function?
Posted 2016年11月13日 GMT-5 08:47 Structural Mechanics Version 5.2a 8 Replies
Please login with a confirmed email address before reporting spam
Has anyone tried to pass variables from COMSOL external materials node that relates to another physics interface?
Example - I use General stress-strain relation option. The strain that I get from solving linear elastic problem (via the external wrapper function) is used by another PDE (within COMSOL GUI) to determine non-local strain. What I want to do is pass this non-local strain to the external wrapper function for further manipulation.
But as I see it, this is not possible because such variables are not recognized, e.g. comp1.hzeq.u2 (where hzeq refers to Helmholtz and u2 its primary variable name) is shown as unknown variable under the external materials node. Does this mean that only variables generated within the solid mechanics node (e.g. comp1.solid.eX) are accessible to the external wrapper function? Is there a workaround.
Thank you
Suresh
Please login with a confirmed email address before reporting spam
You should be able to pass any variable to an External Material. So it seems like it is some syntax or scope issue here. What if you try to wrap whatever you are sending down in a variable defined under Definition->Variables?
Regards,
Henrik
Please login with a confirmed email address before reporting spam
Thank you for your kind response.
To the best of my knowledge, I thought the variables are correctly defined in terms of syntax.
I attach a test file please. Here you will see that the variable mod1.hzeq.H_eqstrain is not recognized under General stress-strain relation (under materials). Also when I try to access a parameter dm from extmat1.state.S2, it does not recognize (under definitions>variables>variable 1).
I have not yet compiled the dll, but I thought it should not matter?
Passing it through the variables also does not work.
Any help much appreciated.
Regards,
Suresh
Attachments:
Please login with a confirmed email address before reporting spam
The correct syntax for the variable in your model is 'root.mod1.H_eqstrain'. (With reference to your first posting, it would have been 'root.comp1.u2' ).
The second question: Do not worry about 'root.extmat1.state.S2'. Your variable definition is correct, but not visible to the expression parser. Once you solve, you can access the variables you have defined.
Regards,
Henrik
Please login with a confirmed email address before reporting spam
Thank you very much for your help.
After changing the syntax, I no longer see the error.
I am happy that there are no restrictions on the variables to be passed. This is so important from coupled physics point of view.
Regards,
Suresh
Please login with a confirmed email address before reporting spam
The examples made available in the link www.comsol.com/model/external-material-examples-structural-mechanics-32331 seem to give an error if I switch over to plane stress problem as shown below. In particular, it appears not to evaluate out of plane displacement component. There is no problem with plane strain or axisymmetric cases.
Is there some manipulation required in the C code please?
Thank you,
Regards,
Suresh
The message (for my own problem) is as follows (very similar to what I get if I used the examples in the link above):
Undefined variable.
- Variable: mod1.wZ
- Geometry: geom1
- Domain: 1
Failed to evaluate variable.
- Variable: mod1.solid.FdzZ
- Defined as: 1+mod1.wZ
Failed to evaluate variable.
- Variable: mod1.solid.Fdlz3
- Defined as: mod1.solid.FdzZ
Failed to evaluate variable.
- Variable: mod1.solid.Cl33
- Defined as: mod1.solid.Fdlz3^2
Failed to evaluate variable.
- Variable: mod1.solid.el33
- Defined as: 0.5*((-1)+mod1.solid.Cl33)
Failed to evaluate variable.
- Variable: extmat1.input.e33
- Defined as: mod1.solid.el33
Failed to evaluate expression.
- Expression: extmat1.input.e33
Input expression for external variables failed.
Failed to evaluate variable.
- Variable: mod1.solid.Sl11
- Defined as: extmat1.output.S11
Failed to evaluate expression.
- Expression: ((-mod1.solid.Sl11)*mod1.solid.d)*dvol
Failed to evaluate Jacobian of expression.
- Expression: (-(mod1.solid.Sl11*test(mod1.solid.el11)+2*mod1.solid.Sl12*test(mod1.solid.el12)+mod1.solid.Sl22*test(mod1.solid.el22)+mod1.solid.Sl33*test(mod1.solid.el33))*mod1.solid.d)*(dvol)
Please login with a confirmed email address before reporting spam
This is a known bug which will fixed in the next release. There is an easy workaround:
1. Add a domain Weak Contribution to the Solid Mechanics interface, and select the domains where the External Stress-Strain Relation are used. Keep the '0' in the 'Weak expression' field.
2. Add an 'Auxiliary Dependent Variable' subnode, and enter 'wZ' as' Field variable name'.
3. In the 'Discretization' section of the 'Auxiliary Dependent Variable' subnode, select 'Discontinuous Lagrange' as 'Shape function type', and set 'Element order' to the same level as you have in the Solid Mechanics interface.
Regards,
Henrik
Please login with a confirmed email address before reporting spam
Thank you so much for your time.
The procedure works very well.
Regards,
Suresh
Please login with a confirmed email address before reporting spam
Hi Suresh,
This is a known bug which will fixed in the next release. There is an easy workaround:
1. Add a domain Weak Contribution to the Solid Mechanics interface, and select the domains where the External Stress-Strain Relation are used. Keep the '0' in the 'Weak expression' field.
2. Add an 'Auxiliary Dependent Variable' subnode, and enter 'wZ' as' Field variable name'.
3. In the 'Discretization' section of the 'Auxiliary Dependent Variable' subnode, select 'Discontinuous Lagrange' as 'Shape function type', and set 'Element order' to the same level as you have in the Solid Mechanics interface.
Regards,
Henrik
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.
Suggested Content
- KNOWLEDGE BASE COMSOL Multiphysics crashes when trying to access the documentation
- BLOG How to Use Lumped Elements to Model a Mechanical System
- KNOWLEDGE BASE The Magnetic and Electric Fields Interface with Electrical Circuit Gives an Unexpected Error for Transient Studies
- BLOG Accessing External Material Models for Structural Mechanics
- KNOWLEDGE BASE How to Debug an External Material