Commit 4713e6d4 by Matthieu Schaller

Added the 1D Noh problem and solution script

parent 8eb92b67
 ############################################################################### # This file is part of SWIFT. # Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # ############################################################################## import h5py from numpy import * # Generates a swift IC file for the Noh problem test in a periodic cubic box # Parameters numPart = 1000 gamma = 5./3. # Gas adiabatic index rho0 = 1. # Background density P0 = 1.e-6 # Background pressure fileName = "noh.hdf5" #--------------------------------------------------- coords = zeros((numPart, 3)) h = zeros(numPart) vol = 2. for i in range(numPart): coords[i,0] = i * vol/numPart + vol/(2.*numPart) h[i] = 1.2348 * vol / numPart # Generate extra arrays v = zeros((numPart, 3)) ids = linspace(1, numPart, numPart) m = zeros(numPart) u = zeros(numPart) m[:] = rho0 * vol / numPart u[:] = P0 / (rho0 * (gamma - 1)) v[coords[:,0]vol/2. ,0] = -1 #-------------------------------------------------- #File file = h5py.File(fileName, 'w') # Header grp = file.create_group("/Header") grp.attrs["BoxSize"] = [vol, vol, vol] grp.attrs["NumPart_Total"] = [numPart, 0, 0, 0, 0, 0] grp.attrs["NumPart_Total_HighWord"] = [0, 0, 0, 0, 0, 0] grp.attrs["NumPart_ThisFile"] = [numPart, 0, 0, 0, 0, 0] grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 grp.attrs["Dimension"] = 1 #Runtime parameters grp = file.create_group("/RuntimePars") grp.attrs["PeriodicBoundariesOn"] = 1 #Units grp = file.create_group("/Units") grp.attrs["Unit length in cgs (U_L)"] = 1. grp.attrs["Unit mass in cgs (U_M)"] = 1. grp.attrs["Unit time in cgs (U_t)"] = 1. grp.attrs["Unit current in cgs (U_I)"] = 1. grp.attrs["Unit temperature in cgs (U_T)"] = 1. #Particle group grp = file.create_group("/PartType0") grp.create_dataset('Coordinates', data=coords, dtype='d') grp.create_dataset('Velocities', data=v, dtype='f') grp.create_dataset('Masses', data=m, dtype='f') grp.create_dataset('SmoothingLength', data=h, dtype='f') grp.create_dataset('InternalEnergy', data=u, dtype='f') grp.create_dataset('ParticleIDs', data=ids, dtype='L') file.close()
 # Define the system of units to use internally. InternalUnitSystem: UnitMass_in_cgs: 1 # Grams UnitLength_in_cgs: 1 # Centimeters UnitVelocity_in_cgs: 1 # Centimeters per second UnitCurrent_in_cgs: 1 # Amperes UnitTemp_in_cgs: 1 # Kelvin # Parameters governing the time integration TimeIntegration: time_begin: 0. # The starting time of the simulation (in internal units). time_end: 0.6 # The end time of the simulation (in internal units). dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units). dt_max: 1e-3 # The maximal time-step size of the simulation (in internal units). # Parameters governing the snapshots Snapshots: basename: noh # Common part of the name of output files time_first: 0. # Time of the first output (in internal units) delta_time: 5e-2 # Time difference between consecutive outputs (in internal units) # Parameters governing the conserved quantities statistics Statistics: delta_time: 1e-5 # Time between statistics output # Parameters for the hydrodynamics scheme SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions InitialConditions: file_name: ./noh.hdf5 # The file to read