找回密码
 注册
Simdroid-非首页
查看: 162|回复: 4

[13.脚本命令] 通过comsol with matlab 有可能实现对节点载荷的任意施加吗

[复制链接]
发表于 2013-7-24 22:43:26 | 显示全部楼层 |阅读模式 来自 湖北武汉
如题,例如想要在某个面上施加一载荷,但是该载荷只知道该区域上某些点的载荷大小。所以如果要用一个函数表示这个载荷,方法就是写插值函数,例如有限元里面的形函数的形式。
这样看起来好像非常之麻烦,特别是当节点数很大的时候。
我的问题是,有没有类似于ansys中直接对节点进行施加载荷的方式。联合comsol和matlab是否可能实现这种过程
发表于 2013-7-25 20:16:47 | 显示全部楼层 来自 上海杨浦区
Simdroid开发平台
那前提你要会用CwM,给你写了一个指定3个点载荷的例子。
代码已出,不接受任何释疑,请自己琢磨。
  1. function out = model
  2. %
  3. % An example about specify point loading on a structure.
  4. % CopyRight to mxio at Shanghai University.
  5. %    See more http://blog.sina.com.cn/mxio
  6. %
  7. %--------------------------------------------------------------------
  8. import com.comsol.model.*
  9. import com.comsol.model.util.*
  10. model = ModelUtil.create('Model');
  11. model.modelNode.create('mod1');
  12. %--------------------------------------------------------------------
  13. % Set up for Points, position and load
  14. num_point = 3;
  15. % Position
  16. point_pos = [0.6, 0.05; 0.7, 0.05; 0.9, 0.05];

  17. % Load
  18. point_load = {'1' '2' '0';'1' '2' '0';'1' '2' '0';};
  19. %--------------------------------------------------------------------
  20. % Set-up for geometry
  21. model.geom.create('geom1', 2);
  22. model.geom('geom1').feature.create('r1', 'Rectangle');
  23. model.geom('geom1').feature('r1').set('size', {'1' '0.05'});

  24. for pt_idx = 1:num_point
  25.     pt_name = ['pt', num2str(pt_idx)];
  26.     model.geom('geom1').feature.create(pt_name, 'Point');
  27.     model.geom('geom1').feature(pt_name).set('p', point_pos(pt_idx,:));
  28.     model.geom('geom1').feature(pt_name).set('createselection', true);
  29. end
  30. model.geom('geom1').run;

  31. %--------------------------------------------------------------------
  32. % set-up for physics
  33. model.physics.create('solid', 'SolidMechanics', 'geom1');
  34. model.physics('solid').feature.create('fix1', 'Fixed', 1);
  35. model.physics('solid').feature('fix1').selection.set([1]);

  36. for pl_idx = 1:num_point
  37.     pl_name = ['pl',num2str(pl_idx)];
  38.     model.physics('solid').feature.create(pl_name, 'PointLoad', 0);
  39.     sl_pt_name = ['geom1_pt',num2str(pl_idx),'_pnt'];
  40.     model.physics('solid').feature(pl_name).selection.named(sl_pt_name);
  41.     model.physics('solid').feature(pl_name).set('Fp', point_load(pl_idx,:));
  42. end

  43. model.physics('solid').feature('lemm1').set('E_mat', 1, 'userdef');
  44. model.physics('solid').feature('lemm1').set('nu_mat', 1, 'userdef');
  45. model.physics('solid').feature('lemm1').set('rho_mat', 1, 'userdef');
  46. model.physics('solid').feature('lemm1').set('E', 1, '300e9[Pa]');
  47. model.physics('solid').feature('lemm1').set('nu', 1, '0.222');
  48. model.physics('solid').feature('lemm1').set('rho', 1, '3900');

  49. %--------------------------------------------------------------------
  50. % set-up for mesh
  51. model.mesh.create('mesh1', 'geom1');
  52. model.mesh('mesh1').feature.create('map1', 'Map');
  53. model.mesh('mesh1').feature('map1').selection.geom('geom1', 2);
  54. model.mesh('mesh1').feature('map1').selection.set([1]);
  55. model.mesh('mesh1').feature('map1').feature.create('dis1', 'Distribution');
  56. model.mesh('mesh1').feature('map1').feature.create('dis2', 'Distribution');
  57. model.mesh('mesh1').feature('map1').feature('dis1').selection.set([1 7]);
  58. model.mesh('mesh1').feature('map1').feature('dis2').selection.set([2]);
  59. model.mesh('mesh1').feature('map1').feature('dis2').set('numelem', '40');
  60. model.mesh('mesh1').run;

  61. %--------------------------------------------------------------------
  62. model.study.create('std1');
  63. model.study('std1').feature.create('stat', 'Stationary');
  64. model.sol.create('sol1');
  65. model.sol('sol1').study('std1');
  66. model.sol('sol1').feature.create('st1', 'StudyStep');
  67. model.sol('sol1').feature('st1').set('study', 'std1');
  68. model.sol('sol1').feature('st1').set('studystep', 'stat');
  69. model.sol('sol1').feature.create('v1', 'Variables');
  70. model.sol('sol1').feature('v1').set('control', 'stat');
  71. model.sol('sol1').feature.create('s1', 'Stationary');
  72. model.sol('sol1').feature('s1').feature.create('fc1', 'FullyCoupled');
  73. model.sol('sol1').feature('s1').feature('fc1').set('termonres', 'auto');
  74. model.sol('sol1').feature('s1').feature('fc1').set('reserrfact', 1000);
  75. model.sol('sol1').feature('s1').feature('fc1').set('termonres', 'auto');
  76. model.sol('sol1').feature('s1').feature('fc1').set('reserrfact', 1000);
  77. model.sol('sol1').feature('s1').feature.remove('fcDef');
  78. model.sol('sol1').attach('std1');

  79. model.sol('sol1').runAll;

  80. model.result.create('pg1', 2);
  81. model.result('pg1').set('data', 'dset1');
  82. model.result('pg1').feature.create('surf1', 'Surface');
  83. model.result('pg1').feature('surf1').set('expr', {'solid.mises'});
  84. model.result('pg1').name('Stress (solid)');
  85. model.result('pg1').feature('surf1').feature.create('def', 'Deform');
  86. model.result('pg1').feature('surf1').feature('def').set('expr', {'u' 'v'});
  87. model.result('pg1').feature('surf1').feature('def').set('descr', 'Displacement field (Material)');

  88. out = model;
复制代码
回复 不支持

使用道具 举报

 楼主| 发表于 2013-7-26 12:14:01 | 显示全部楼层 来自 湖北武汉
mxio 发表于 2013-7-25 20:16
那前提你要会用CwM,给你写了一个指定3个点载荷的例子。
代码已出,不接受任何释疑,请自己琢磨。 ...

谢谢指教,我会认真看你的代码的
回复 不支持

使用道具 举报

发表于 2013-7-26 15:09:02 | 显示全部楼层 来自 北美地区
mxio 发表于 2013-7-25 20:16
那前提你要会用CwM,给你写了一个指定3个点载荷的例子。
代码已出,不接受任何释疑,请自己琢磨。 ...

mxio 的却是本版的高手中的高手
回复 不支持

使用道具 举报

发表于 2014-2-21 19:21:32 | 显示全部楼层 来自 四川成都
COMSOL里设置某一位置(或节点)上材料属性必须建立实体点吗??
COMSOL里有没有材料属性矩阵?
也就是:COMSOL能不能像ANSYS那样直接访问网格中的节点并对其设置
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-3-29 07:39 , Processed in 0.031557 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表