Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
geometry_parametric.py 3.73 KiB
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 14 10:39:21 2020

@author: Lucia
"""

import numpy as np
import math as m

import vmf_test
import vmf_hollow_OD
import vmf_hollow_ID
import vmf_bisection

from utils_geo import *

# f2py -c name.f95 -m name

from scipy.spatial import distance

from scipy.optimize import minimize

from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection
import matplotlib.pyplot as plt

import time
import sys

from Auto_geometry_parametric import *

file = open('Radius.dat','a+')
file.close()
file = open('Density.dat','a+')
file.close()

  
initial_data="""
Geometry                number
---------------        -------    
2-Triangles               2
Diagonals                 3
Rombo dodecahedron        4
6-Star                    5 
Octet                     6
Hexagon                   7
Auxetic                   8
Octahedron v1             9
Octahedron v2            91
Octahedron v3 (hollow)   92
Cirp USF                 10

"""
print (initial_data)
print("1. Specify geometry number: ")
name= input()
print ("2. Number of voxels, 8,32,64,128...")
#rho=input()
rho=str(128)
print (rho)

print(name, rho)

vf_radius="""
3. What will you introduce a or b?:
   a) volume fraction 
   b) radius
Insert a or b   
"""
print (vf_radius)
vfr= input()
if vfr=="a":
    if name =="92":
        print ("NOTE: geo 92 does not work with option a")
        sys.exit()
    print ("you chose to introduce volume fraction")

if vfr=="b":
    print ("you chose to introduce radius")

#dimension of the lattice/ NUMBER OF UNIT CELL IN EACH DIRECTION
print ("4. Number of unit cells in each direction")
print ("length")
length = int(input())
print ("width")
width = int(input())
print("height")
height = int(input())

A=[]
B=[]
x_cell=0
y_cell=0
z_cell=0
r=0
print("5. Set size of unit cell")
sb=float(input())
if  vfr=="b":
  if name!="92":
    print ("6.b. Specify radius of struts, from 0 to "+ str(sb))
    r=float(input()) 
  elif name=="92":
    print("HOLLOW geometry, inner radius dimension: 0.8 x outer radius")
    print ("6.b. Specify outer radius of hollow struts, from 0 to "+ str(sb))       
    r=float(input())    
    
  if r<=0. or r>=sb:
    r=sb/2.
    print("Radius of struts enforced to ", r);

if  vfr=="a":
    if name!="8":
      print( "6.a. Set volume fraction from 0 to 1")
      vfraction=float(input())
      if vfraction<=0. or vfraction>=1.:
        vfraction=0.2
        print( "Volume fraction enforced to ", vfraction)
    if name=="8":
      print( "6.a. Set volume fraction from 0 to 0.15")
      vfraction=float(input())
      if vfraction<=0. or vfraction>=0.15:
        vfraction=0.1
        print( "Volume fraction enforced to ", vfraction)

if  vfr=="b":
    vfraction=0.

bow_h=sb/2.
bow_angle=75.
if  name=="8":
    print ("bow height between 0 and size of unit cell ", sb, " chosen:", bow_h)
    bow_h=float(input())
    if bow_h>=sb:
      bow_h=sb/2.
      print ("bow height between 0 and size of unit cell ", sb, " enforced:", bow_h)
    limit_angle=1.1*math.atan(sb/bow_h)*180./math.pi
    bow_angle=limit_angle/2.+90./2.
    print ("bow angle between "+str(limit_angle)+"º and 90º, chosen: "+ str(bow_angle)+"º")    
    bow_angle=float(input())    
    if bow_angle>=90. or bow_angle<=limit_angle:
      bow_angle=limit_angle/2.+90./2.
      print ("bow angle between "+str(limit_angle)+"º and 90º, enforced: "+ str(bow_angle)+"º")

Radius=r
VmFr=vfraction
cell_name=name
Geo, Radi = Geo_generator(cell_name, rho, vfr, length, width, height, sb, Radius, VmFr, bow_h, bow_angle)
V_R_S = [VmFr, Radi, sb]

print("Create geo file ", Geo, " cell type ", cell_name, " of volume fraction type", vfr, "with as results: volume fraction ", VmFr," Radius ", Radi)