本代码可用于平面桁架结构的计算。

本文是根据基于Python的结构力学位移法编程求解的另一版本的更新,内容基本相同,背景介绍此处省略。仅展示最终代码的运行过程。

由于Fortran编程语言使用比较困难一些,所以很少涉及,特别是其缺少一些相应的函数调用,过程要更复杂一些,而且调试过程也较麻烦。但就学习而言,值得去尝试一下,谁知道以后会不会用到呢。本文使用Intel Parallel Studio XE 2020和vs2019。

完整代码


program mainuse lapack95implicit nonecharacter*100 pathinteger num,point,i,j,counterreal,dimension(:),allocatable:: angle,length,uv,forces,uv_d,forces_dinteger,dimension(:),allocatable:: num1,num2,location,creal,dimension(:,:,:),allocatable:: mreal,dimension(:,:),allocatable:: mm,mm_d,a,wq,tempwrite(*,'("input file road:")')read*,pathopen(1,file=path)read(1,*)num,pointallocate(num1(num))allocate(num2(num))allocate(angle(num))allocate(length(num))allocate(m(num,4,4))allocate(uv(point*2))allocate(forces(point*2))allocate(mm(point*2,point*2))allocate(a(point*2,point*2))allocate(c(point*2))allocate(location(point*2))allocate(temp(point*2,2))!读入杆件位点,计算刚度矩阵do i=1,numread(1,*)num1(i),num2(i),angle(i),length(i)call mat(angle(i),length(i),i,num,m)enddo !读入结点的力和位移do i=1,pointread(1,*)uv(2*i-1),uv(2*i),forces(2*i-1),forces(2*i)enddo!关闭读入文件close(1)!扩阶矩阵forall(i=1:point*2,j=1:point*2)mm(i,j)=0do i=1,numcall rebig(i,m,num,num1(i),num2(i),point,mm)   enddo!获取位移向量的非0元素及其位置counter=count(uv/=0)allocate(mm_d(point*2-counter,point*2-counter))allocate(uv_d(point*2-counter))allocate(forces_d(point*2-counter))allocate(wq(point*2-counter,2))forall(i=1:2*point)location(i)=0call get_location(uv,location,counter,point)!获取缩减后的位移和力call less(forces,forces_d,location,point,counter)call less(uv,uv_d,location,point,counter)!获取缩减后的刚度矩阵call mless(mm,mm_d,location,point,counter)!刚度矩阵求逆a=mm_dcall getrf(a,c)call getri(a,c)!计算得位移矩阵forall(i=1:point*2-counter,j=1:1) wq(i,j)=forces_d(i)wq=matmul(a,wq)forall(i=1:point*2-counter,j=1:1) uv_d(i)=wq(i,j)do i=1,point*2-counteruv(location(point*2-counter-i+1))=uv_d(i)enddo!计算得力矩阵forall(i=1:point*2,j=1:1) temp(i,j)=uv(i)temp=matmul(mm,temp)forall(i=1:point*2,j=1:1) forces(i)=temp(i,j)!输出到结果文档open(2,file='result.txt')do i=1,pointwrite(2,100)i,uv(2*i-1),uv(2*i)enddodo i=1,pointwrite(2,200)i,forces(2*i-1),forces(2*i)enddo100 format(1x,'结点',i1,'的位移:',f6.2,',',f6.2)
200 format(1x,'结点',i1,'的力:',f6.2,',',f6.2)   close(2)print*,'done'pausecontains
subroutine mat(a,l,s,n,ma)integer s,n,i,jreal lamda,miu,a,l,ma(n,4,4)lamda=cosd(a)miu=sind(a)ma(s,1,:)=(/lamda**2,miu*lamda,-lamda**2,-lamda*miu/)ma(s,2,:)=(/miu*lamda,miu**2,-lamda*miu,-miu**2/)ma(s,3,:)=(/-lamda**2,-miu*lamda,lamda**2,lamda*miu/)ma(s,4,:)=(/-lamda*miu,-miu**2,lamda*miu,miu**2/)forall(i=1:4,j=1:4) ma(s,i,j)=ma(s,i,j)/l
end subroutine matsubroutine rebig(s,ma,n,n1,n2,p,mass)integer s,n,n1,n2,p,i,jreal ma(n,4,4)real mas(p*2,p*2),mass(p*2,p*2)forall(i=1:p*2,j=1:p*2)mas(i,j)=0mas(n1*2-1,n1*2-1)=ma(s,1,1);mas(n1*2-1,n1*2)=ma(s,1,2)mas(n1*2-1,n2*2-1)=ma(s,1,3);mas(n1*2-1,n2*2)=ma(s,1,4)mas(n1*2,n1*2-1)=ma(s,2,1);mas(n1*2,n1*2)=ma(s,2,2)mas(n1*2,n2*2-1)=ma(s,2,3);mas(n1*2,n2*2)=ma(s,2,4)mas(n2*2-1,n1*2-1)=ma(s,3,1);mas(n2*2-1,n1*2)=ma(s,3,2)mas(n2*2-1,n2*2-1)=ma(s,3,3);mas(n2*2-1,n2*2)=ma(s,3,4)mas(n2*2,n1*2-1)=ma(s,4,1);mas(n2*2,n1*2)=ma(s,4,2)mas(n2*2,n2*2-1)=ma(s,4,3);mas(n2*2,n2*2)=ma(s,4,4)forall(i=1:p*2,j=1:p*2)mass(i,j)=mass(i,j)+mas(i,j)
end subroutine rebigsubroutine get_location(uv_,location_,number,p)integer p,number,i,location_(2*p),nreal uv_(2*p)n=numberdo while(n>0)do i=1,p*2if(uv_(i)/=0)thenlocation(n)=in=n-1endifenddoenddo
end subroutine get_locationsubroutine less(old,new_,loca,p,counter_) integer counter_,loca(counter_),p,i,creal new_(p*2-counter_),old(2*point)c=counter_i=1do while(c>0)new_(i)=old(loca(c))c=c-1i=i+1enddo
end subroutine lesssubroutine mless(mm_,mm_d_,location_,p,count)integer count,location_(count),p,i,j,q,k,s,tfreal mm_d_t(p*2-count,p*2-count),mm_d_(p*2-count,p*2-count),mm_(2*p,2*p),temp((p*2-count)**2)q=1tf=0do i=1,2*pdo j=1,2*pdo k=1,2*p-countdo s=1,2*p-countif (i==location_(k).and.j==location_(s))thentf=1endifenddoenddoif(tf==1)thentemp(q)=mm_(i,j)q=q+1endiftf=0enddoenddomm_d_t=reshape(temp,(/p*2-count,p*2-count/))forall(i=1:p*2-count,j=1:p*2-count)mm_d_(i,j)=mm_d_t(j,i)
end subroutine mlessend

基于Fortran的结构力学位移法编程求解相关推荐

  1. 基于Python的结构力学位移法编程求解

    如果想用Fortran编,可以参考基于Fortran的结构力学位移法编程求解 目录 1.背景介绍 2.编程思路 2.1 结点编号.元素编号,建立总体坐标系xoy 2.2 建立各元素在总体坐标系xoy ...

  2. matlab 矩阵位移法编程 结构力学,matlab 矩阵位移法编程 结构力学

    矩阵位移法编程大作业 (091210211) 一.编制原理 本程序的原理是基于结构力学矩阵位移法原理,以结构结点位移作基本未知量,将要分析的结构拆成已知节点力-结点力位移关系的单跨梁集合,通过强令结构 ...

  3. matlab 矩阵位移法编程 结构力学,matlab 矩阵位移法编程 结构力学.doc

    matlab 矩阵位移法编程 结构力学.doc 矩阵位移法编程大作业(091210211)一.编制原理本程序的原理是基于结构力学矩阵位移法原理,以结构结点位移作基本未知量,将要分析的结构拆成已知节点力 ...

  4. C语言练习题:三色球分组,编程计算三色球问题。若一个口袋中放有12个球,其中有3个红色的,3个白色的,6个黑色的,从中任取8个球,问共有多少种不同的颜色搭配?请用穷举法编程求解。

    编程计算三色球问题.若一个口袋中放有12个球,其中有3个红色的,3个白色的,6个黑色的,从中任取8个球,问共有多少种不同的颜色搭配?请用穷举法编程求解. **输入格式:无 **输出格式:"i ...

  5. 矩阵位移法是用于求解杆系结构的计算机方法,结构力学的教学思路

    结构力学的教学思路 2019-10-14 版权声明 举报文章 一.经典位移法(以下简称位移法)和矩阵位移法都是求解杆系结构的基本方法,是结构力学课程中两个十分重要的内容,两种方法都是结构力学课程中讲授 ...

  6. C语言编程实现求解应力向量,基于MATLAB与Visual C 实现主应力的编程求解.doc

    您所在位置:网站首页 > 海量文档 &nbsp>&nbsp计算机&nbsp>&nbspmatlab 基于MATLAB与Visual C 实现主应力的编 ...

  7. 矩阵位移法matlab编程,矩阵位移法_MATLAB_GUI.doc

    Matrix_Displacement_Method--by MATLAB GUI PAGE58 / NUMPAGES64 yanfeng39@zju.edu.cn <结构力学>课程设计之 ...

  8. 用gulp计算合金弹性常数_考研结构力学 用3种方法解东南大学位移法大题

    位移法中含无穷刚度杆的结构是考研结构力学的一大难点,很多热门院校都喜欢出这类型的题目,下面以两道有复杂牵连位移的含无穷刚度杆位移法题目为例,对三种解法进行讲解,题目取自东南大学真题和烟台大学真题. 1 ...

  9. 结构力学计算机矩阵位移法,结构力学-矩阵位移法.ppt

    <结构力学-矩阵位移法.ppt>由会员分享,可在线阅读,更多相关<结构力学-矩阵位移法.ppt(42页珍藏版)>请在装配图网上搜索. 1.结构力学,2 / 42,第七节 平面刚 ...

最新文章

  1. 2018.08.10 atcoder Median Sum(01背包)
  2. 循环队列-队列的顺序表示和实现
  3. 开发商微信选房后不退认筹金_网曝!青岛恒大文化旅游城1400余名购房者欲退认筹金,开发商表示.........
  4. docker pytorch
  5. kubernetes之五:资源管理
  6. Win10电脑如何定时关机
  7. 实现平衡二叉排序树的各种算法(包括二叉树的递归遍历、非递归遍历)
  8. 使用WUCDCreator将SCSI、RAID、SATA、SAS驱动程序集成到光盘中
  9. solidworks2016详细安装教程
  10. python写斗地主游戏_基于python的简单斗地主实现-Go语言中文社区
  11. 计算机显卡类型有,显卡类型分几种|笔记本显卡类型
  12. 爬取实习僧并进行数据可视化
  13. css3里面的放大镜特效,用纯css3实现的图片放大镜特效效果非常不错
  14. 五分钟带你了解《操作系统原理》
  15. 中国联通广州软件研究院 软件开发岗二面(技术面)
  16. 深度模型的日志异常检测,还有谁不会?
  17. 做一个微信消息的日期展示
  18. 同比、定比和环比分析
  19. node js 通过url下载文件到本地指定目录
  20. java 之file文件/目录创建

热门文章

  1. 【CSS】用CSS画太极图
  2. springboot不停机更新(配合Nginx优雅发版)
  3. 安装炫酷桌面himawaripy实施卫星地图
  4. 排序算法(分类,时间复杂度)(快速排序,插入排序,希尔排序,选择排序,冒泡排序)
  5. 标签云打印/微信小程序蓝牙标签打印开放平台功能
  6. PSINS不可交换(圆锥/划桨)误差补偿
  7. android wifi取消自动连接网络,Android 11新增无线网络连接安全策略 可以不自动连接某些特定WiFi...
  8. 如何判断某一个微信公众号上面的文章的阅读量是不是刷上来的?
  9. 小乐乐上台阶【斐波那契】
  10. RGB-D相机(Azure Kinect DK)SDK安装