@@ -172,6 +172,7 @@ def plot_avg_velocity_vs_noise(
172172 noise_range : tuple [float , float ] = (0.0 , 5.0 ),
173173 noise_steps : int = 10 ,
174174 n_realizations : int = 1 ,
175+ verbose : bool = False ,
175176) -> None :
176177 """
177178 Plot the time-averaged normalized order parameter vs noise for different system sizes (N),
@@ -199,15 +200,17 @@ def plot_avg_velocity_vs_noise(
199200 for idx , nb in enumerate (num_boids_list ):
200201 box_size = np .sqrt (nb / density )
201202 avg_orders = []
202- print (f"Simulating for N={ nb } , L={ box_size :.2f} , density={ density } " )
203+ if verbose :
204+ print (f"Simulating for N={ nb } , L={ box_size :.2f} , density={ density } " )
203205 for noise in noises :
204206 vals = []
205207 for rep in range (n_realizations ):
206208 val = simulate_vicsek (nb , noise , density = density )
207209 vals .append (val )
208210 mean_val = float (np .mean (vals ))
209211 avg_orders .append (mean_val )
210- print (f" noise={ noise :.3f} , phi={ mean_val :.4f} " )
212+ if verbose :
213+ print (f" noise={ noise :.3f} , phi={ mean_val :.4f} " )
211214 marker = markers [idx % len (markers )]
212215 plt .scatter (
213216 noises , avg_orders , label = f"N={ nb } , L={ box_size :.1f} " , marker = marker , s = 60
@@ -224,6 +227,7 @@ def plot_avg_velocity_vs_density(
224227 density_steps : int = 20 ,
225228 noise : float = 2.0 ,
226229 box_size : float = 5 ,
230+ verbose : bool = False ,
227231) -> None :
228232 """
229233 Plot the time-averaged normalized order parameter vs density for a fixed noise.
@@ -253,15 +257,17 @@ def plot_avg_velocity_vs_density(
253257 num_boids = int (density * box_size ** 2 )
254258 # If the number of boids is too small, skip to avoid noisy results
255259 if num_boids <= 5 :
256- print (
257- f"Box size: { box_size } , density: { density :.2f} , num_boids: { num_boids } (skipped)"
258- )
260+ if verbose :
261+ print (
262+ f"Box size: { box_size } , density: { density :.2f} , num_boids: { num_boids } (skipped)"
263+ )
259264 continue
260265 avg_v = simulate_vicsek (num_boids = num_boids , noise = noise , density = density )
261266 avg_velocities .append (avg_v )
262- print (
263- f"Box size: { box_size } , density: { density :.2f} , avg velocity: { avg_v :.4f} "
264- )
267+ if verbose :
268+ print (
269+ f"Box size: { box_size } , density: { density :.2f} , avg velocity: { avg_v :.4f} "
270+ )
265271 # Crop densities to match the length of avg_velocities (in case some were skipped)
266272 densities = densities [- len (avg_velocities ) :]
267273 plt .scatter (densities , avg_velocities , marker = "o" )
0 commit comments