it.command(""" config cfd element cfd ini density {} element cfd ini visc {} cfd porosity poly cfd buoy on cfd interval 0 element cfd history id 3 zvelocity id 1 plot add hist 2 vs 1 """.format(fluid_density, fluid_viscosity)) element_volume = ca.volume() oldu = ca.velocity() old_force = (ca.drag().T/element_volume).T/fluid_density old_porosity = ca.porosity() r_factor = 0.5 smallest_size = 0.00095 time = 0.0 total_time = 4.0 max_dt = 0.0001 while time < total_time: dt = 100.0 if (ca.velocity().max()>1.0e-7): dt = float(0.5*smallest_size/ca.velocity().max()) if (max_dt < dt): dt = max_dt it.command("solve time {}".format(dt)) it.command("cfd update")
cfd relax 1 cfd update call particles.p3dat """.format(fluid_density, fluid_viscosity)) element_volume = ca.volume() dt = 0.005 oldu = ca.velocity() r_factor = 1.0 for i in range(10): it.command("solve age {}".format(it.mech_age()+dt)) print "sending solve time" cfd_link.send_data(dt) # solve interval n=ca.porosity() cfd_link.send_data(n) ca.set_extra(1, np.zeros(it.element.cfd.count())) ca.set_extra(2, np.zeros(it.element.cfd.count())) ca.set_extra(3, np.zeros((it.element.cfd.count(),3))) for b in it.ball.cfd.list(): for e,v in zip(b.elements(), b.overlaps()): e.set_extra(1, e.extra(1)+v*b.ball().radius()) e.set_extra(2, e.extra(2)+v) e.set_extra(3, e.extra(3)+v*b.ball().vel()) dbar = 2*ca.extra(1)/ca.extra(2) ubar = (ca.extra(3).T/ca.extra(2)).T du = np.linalg.norm(ubar.T - ca.velocity().T,axis=0) re = (du*fluid_density*dbar/fluid_viscosity).T beta = fluid_viscosity*(1-n)/dbar**2/n*(150*(1-n)+1.75*re)/fluid_density #print beta, ubar
element cfd ini visc {} cfd porosity poly cfd buoy on cfd relax 1 cfd update call particles.p3dat """.format(fluid_density, fluid_viscosity)) element_volume = ca.volume() dt = 0.005 oldu = ca.velocity() r_factor = 1.0 for i in range(20): it.command("solve age {}".format(it.mech_age() + dt)) print "sending solve time" cfd_link.send_data(dt) # solve interval cfd_link.send_data(ca.porosity()) new_force = (ca.drag().T / element_volume).T / fluid_density cfd_link.send_data(new_force) print " cfd solve started" ca.set_pressure(cfd_link.read_data()) ca.set_pressure_gradient(cfd_link.read_data()) newu = cfd_link.read_data() ca.set_velocity(oldu * (1 - r_factor) + newu * r_factor) oldu = newu print " cfd solve ended" cfd_link.send_data(0.0) it.command('plot bitmap filename "porous2.png"')
cfd porosity poly cfd buoy on cfd relax 1 cfd update call particles.p3dat """.format(fluid_density, fluid_viscosity)) element_volume = ca.volume() dt = 0.005 oldu = ca.velocity() r_factor = 1.0 for i in range(20): it.command("solve age {}".format(it.mech_age()+dt)) print "sending solve time" cfd_link.send_data(dt) # solve interval cfd_link.send_data(ca.porosity()) new_force = (ca.drag().T/element_volume).T/fluid_density cfd_link.send_data(new_force) print " cfd solve started" ca.set_pressure(cfd_link.read_data()) ca.set_pressure_gradient(cfd_link.read_data()) newu = cfd_link.read_data() ca.set_velocity(oldu*(1-r_factor)+newu*r_factor) oldu = newu print " cfd solve ended" cfd_link.send_data(0.0) it.command('plot bitmap filename "porous2.png"')