|   1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 | import shamrock
gamma = 5./3.
rho_g = 1
target_tot_u = 1
bmin = (-0.6,-0.6,-0.6)
bmax = ( 0.6, 0.6, 0.6)
N_target_base = 4e6
compute_multiplier = shamrock.sys.world_size()
scheduler_split_val = int(2e6)
scheduler_merge_val = int(1)
N_target = N_target_base*compute_multiplier
xm,ym,zm = bmin
xM,yM,zM = bmax
vol_b = (xM - xm)*(yM - ym)*(zM - zm)
part_vol = vol_b/N_target
#lattice volume
part_vol_lattice = 0.74*part_vol
dr = (part_vol_lattice / ((4./3.)*3.1416))**(1./3.)
pmass = -1
ctx = shamrock.Context()
ctx.pdata_layout_new()
model = shamrock.get_Model_SPH(context = ctx, vector_type = "f64_3",sph_kernel = "M6")
model.init_scheduler(scheduler_split_val,scheduler_merge_val)
bmin,bmax = model.get_ideal_fcc_box(dr,bmin,bmax)
xm,ym,zm = bmin
xM,yM,zM = bmax
model.resize_simulation_box(bmin,bmax)
model.add_cube_fcc_3d(dr, bmin,bmax)
xc,yc,zc = model.get_closest_part_to((0,0,0))
ctx.close_sched()
del model
del ctx
ctx = shamrock.Context()
ctx.pdata_layout_new()
model = shamrock.get_Model_SPH(context = ctx, vector_type = "f64_3",sph_kernel = "M6")
cfg = model.gen_default_config()
#cfg.set_artif_viscosity_Constant(alpha_u = 1, alpha_AV = 1, beta_AV = 2)
#cfg.set_artif_viscosity_VaryingMM97(alpha_min = 0.1,alpha_max = 1,sigma_decay = 0.1, alpha_u = 1, beta_AV = 2)
cfg.set_artif_viscosity_VaryingCD10(alpha_min = 0.0,alpha_max = 1,sigma_decay = 0.1, alpha_u = 1, beta_AV = 2)
cfg.set_boundary_periodic()
cfg.set_eos_adiabatic(gamma)
cfg.print_status()
model.set_solver_config(cfg)
model.init_scheduler(int(1e6),1)
bmin = (xm - xc,ym - yc, zm - zc)
bmax = (xM - xc,yM - yc, zM - zc)
xm,ym,zm = bmin
xM,yM,zM = bmax
model.resize_simulation_box(bmin,bmax)
model.add_cube_fcc_3d(dr, bmin,bmax)
vol_b = (xM - xm)*(yM - ym)*(zM - zm)
totmass = (rho_g*vol_b)
#print("Total mass :", totmass)
pmass = model.total_mass_to_part_mass(totmass)
model.set_value_in_a_box("uint","f64", 0 , bmin,bmax)
rinj = 0.008909042924642563*2/2
#rinj = 0.008909042924642563*2*2
#rinj = 0.01718181
u_inj = 1
model.add_kernel_value("uint","f64", u_inj,(0,0,0),rinj)
model.set_particle_mass(pmass)
model.set_cfl_cour(0.01)
model.set_cfl_force(0.01)
t_sum = 0
t_target = 0.1
current_dt = 1e-7
i = 0
i_dump = 0
while t_sum < t_target:
    #print("step : t=",t_sum)
    next_dt = model.evolve(t_sum,current_dt, False, "dump_"+str(i_dump)+".vtk", False)
    if i % 1 == 0:
        i_dump += 1
    t_sum += current_dt
    current_dt = next_dt
    if (t_target - t_sum) < next_dt:
        current_dt = t_target - t_sum
    i+= 1
    if i > 5:
        break
res_rate,res_cnt = model.solver_logs_last_rate(), model.solver_logs_last_obj_count()
if shamrock.sys.world_rank() == 0:
    print("result rate :",res_rate)
    print("result cnt :",res_cnt)
 |