• 任重而道远
    了解作者
  • Python
    开发工具
  • 2KB
    文件大小
  • zip
    文件格式
  • 2
    收藏次数
  • 10 积分
    下载积分
  • 65
    下载次数
  • 2018-06-24 11:01
    上传日期
在规则几何区域能随机生成三维混凝土骨料,为混凝土细观模拟研究所使用。
3D-sphere-random-1.zip
  • 3D-sphere-random-1.py
    13KB
内容介绍
# -*- coding: cp936 -*- import time from random import* from abaqus import* from abaqusConstants import * import assembly import math import displayGroupMdbToolset as dgm start_time =time.clock() def RandomFunc(vf,n,x0,y0,z0): #### 修改自 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ########### ## ## [二次开发] Python做的改进的随机纤维束模型的程序(2D和3D)by panqingnuaa ## http://forum.simwe.com/thread-1031539-1-1.html ## ########################################################## ##### ######### RandomFunc(vf,n,x0,y0,z0) ### ## ## vf 体积分数;;n 颗粒个数;x0,y0,z0 立方体大小 ## R 颗粒半径 ## Dis_b 避免与边界相切 ## count_w 布点不成功的颗粒个数(体积分数大的时候可能出现) ## ############## R = x0*y0*z0*vf/n R = R*0.75/math.pi R = R**(1.0/3.0) Dis_b = R/2.0 count_w = 0 dis_ini = 1000.0*(x0**2+y0**2+z0**2) x=random()*(x0)+R+Dis_b y=random()*(y0)+R+Dis_b z=random()*(z0)+R+Dis_b if (x0-R-Dis_b<x<x0-R+Dis_b)or(x0+R-Dis_b<x<=x0+R+Dis_b): x=x0-R+Dis_b+random()*2.0*(R-Dis_b) if (y0-R-Dis_b<y<y0-R+Dis_b)or(y0+R-Dis_b<y<=y0+R+Dis_b): y=y0-R+Dis_b+random()*2.0*(R-Dis_b) if (z0-R-Dis_b<z<z0-R+Dis_b)or(z0+R-Dis_b<z<=z0+R+Dis_b): z=z0-R+Dis_b+random()*2.0*(R-Dis_b) xyz=[(x,y,z)] ######################### 中心在边界则增加点 if (x>=x0-R+Dis_b): if(y>=y0-R+Dis_b): if(z>=z0-R+Dis_b): xyz.append((x-x0,y,z)) xyz.append((x-x0,y-y0,z)) xyz.append((x-x0,y-y0,z-z0)) xyz.append((x,y-y0,z)) xyz.append((x,y-y0,z-z0)) xyz.append((x,y,z-z0)) xyz.append((x-x0,y,z-z0)) else: xyz.append((x-x0,y,z)) xyz.append((x-x0,y-y0,z)) xyz.append((x,y-y0,z)) else: if(z>=z0-R+Dis_b): xyz.append((x-x0,y,z)) xyz.append((x,y,z-z0)) xyz.append((x-x0,y,z-z0)) else: xyz.append((x-x0,y,z)) else: if(y>=y0-R+Dis_b): if(z>=z0-R+Dis_b): xyz.append((x,y-y0,z)) xyz.append((x,y-y0,z-z0)) xyz.append((x,y,z-z0)) else: xyz.append((x,y-y0,z)) else: if(z>=z0-R+Dis_b): xyz.append((x,y,z-z0)) ######################## 初始点结束,开始后续点 for i in range(n-1): flag_loop=1 flag_cout = 1 while flag_loop==1: x=random()*(x0)+R+Dis_b y=random()*(y0)+R+Dis_b z=random()*(z0)+R+Dis_b flag_loop=0 if (x0-R-Dis_b<x<x0-R+Dis_b)or(x0+R-Dis_b<x<=x0+R+Dis_b): x=x0-R+Dis_b+random()*2.0*(R-Dis_b) if (y0-R-Dis_b<y<y0-R+Dis_b)or(y0+R-Dis_b<y<=y0+R+Dis_b): y=y0-R+Dis_b+random()*2.0*(R-Dis_b) if (z0-R-Dis_b<z<z0-R+Dis_b)or(z0+R-Dis_b<z<=z0+R+Dis_b): z=z0-R+Dis_b+random()*2.0*(R-Dis_b) ########### 循环标记 flag_x=0 flag_y=0 flag_z=0 ################# 面相关标记 flag_xy=0 flag_zx=0 flag_yz=0 flag_xyz=0 ############ 线及点相关标记 dist_x=dis_ini dist_y=dis_ini dist_z=dis_ini dist_xy=dis_ini dist_yz=dis_ini dist_zx=dis_ini dist_xyz=dis_ini distmin=(2*R*1.05)**2 ########### 循环比较距离 放置点 distcau = [] distfin = dis_ini for j in range(len(xyz)): dist = (x-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-xyz[j][2])**2 distcau.append(dist) if (x>=x0-R+Dis_b): if(y>=y0-R+Dis_b): if(z>=z0-R+Dis_b): flag_x=1 flag_y=1 flag_z=1 flag_xy=1 flag_yz=1 flag_zx=1 flag_xyz=1 dist_x = (x-x0-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-xyz[j][2])**2 dist_y = (x-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-xyz[j][2])**2 dist_z = (x-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 dist_xyz = (x-x0-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 dist_xy = (x-x0-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-xyz[j][2])**2 dist_yz = (x-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 dist_zx = (x-x0-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 else: flag_x=1 flag_y=1 flag_xy=1 dist_x = (x-x0-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-xyz[j][2])**2 dist_y = (x-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-xyz[j][2])**2 dist_xy = (x-x0-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-xyz[j][2])**2 else: if(z>=z0-R+Dis_b): flag_x=1 flag_z=1 flag_zx=1 dist_x = (x-x0-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-xyz[j][2])**2 dist_z = (x-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 dist_zx = (x-x0-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 else: flag_x=1 dist_x = (x-x0-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-xyz[j][2])**2 else: if(y>=y0-R+Dis_b): if(z>=z0-R+Dis_b): flag_y=1 flag_z=1 flag_yz=1 dist_y = (x-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-xyz[j][2])**2 dist_z = (x-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 dist_yz = (x-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 else: flag_y=1 dist_y = (x-xyz[j][0])**2 + (y-y0-xyz[j][1])**2 +(z-xyz[j][2])**2 else: if(z>=z0-R+Dis_b): flag_z=1 dist_z = (x-xyz[j][0])**2 + (y-xyz[j][1])**2 +(z-z0-xyz[j][2])**2 if flag_xyz==1: distcau.append(dist_xyz) if flag_xy==1: distcau.append(dist_xy) if flag_yz==1: distcau.append(dist_yz) if flag_zx==1: distcau.append(dist_zx) if flag_x==1: distcau.append(dist_x) if flag_y==1:
评论
  • we565656 2020-11-01 23:44:06
    不好
相关推荐
  • 随机骨料.zip
    Python用于生成多边形骨料的混凝土细观模型
  • qpopper2.53.tar.Z
    pop3 server
  • imap-4.7.tar.Z
    被广泛使用的email服务器 /IMAPD/POPD
  • 53308459Add_Dlt_TabCtrl.rar
    Tab分页的删除和添加,实现分页动态的管理。
  • ns-allinone-2.33.tar.gz
    ns2.33这是目前比较新的ns2版本,欢迎下载
  • NetVideoActiveX23.rar
    海康威视 网络监控插件 带有例子 和开发的dll文件,非常易用
  • UR054g_(R01).zip
    法国inventel的ur054g(r01)v1.1的无线网卡驱动。
  • eat.rar
    外卖叫餐系统,采用ACCESS数据库,有完整天的后台管理系统
  • KSTVTUNE.ZIP
    装摄像头驱动需要用到的文件。Microsoft DirectX 9 SDK
  • Skin++.rar
    知名的Skin++界面库,内含所有库文件和大量皮肤文件.该库使用方便,可以减少您美化程序的痛苦.本版是破解版,没有注册提示.但只供学习研究使用哦,不要用在商业用途.