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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""wavefront2.0
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colab.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1ykAe4zCWqT3usLvm_MhJpsKBOMGGpYbs
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
import torch
|
| 11 |
+
import torch.nn as nn
|
| 12 |
+
import numpy as np
|
| 13 |
+
import matplotlib.pyplot as plt
|
| 14 |
+
|
| 15 |
+
# Parameters
|
| 16 |
+
num_nodes = 100
|
| 17 |
+
time_steps = 1000 # Number of time steps for signal generation
|
| 18 |
+
frequency = 1 # Frequency of the sinusoidal wave (Hz)
|
| 19 |
+
amplitude = 1.0 # Amplitude of the sinusoidal wave
|
| 20 |
+
sampling_rate = 1000 # Samples per second
|
| 21 |
+
infrared_voltage = 0.7 # Simulated infrared voltage for storage
|
| 22 |
+
pulse_width_modulation_frequency = 50 # Frequency of PWM in Hz
|
| 23 |
+
|
| 24 |
+
# SPWM Signal Generation
|
| 25 |
+
def generate_spwm_signal(time, frequency, amplitude):
|
| 26 |
+
# Generate a sinusoidal signal
|
| 27 |
+
sine_wave = amplitude * np.sin(2 * np.pi * frequency * time)
|
| 28 |
+
# Generate PWM signal based on the sinusoidal signal
|
| 29 |
+
pwm_signal = np.where(sine_wave > np.random.rand(len(time)), 1, 0)
|
| 30 |
+
return pwm_signal
|
| 31 |
+
|
| 32 |
+
# Infrared Energy Storage
|
| 33 |
+
def infrared_storage(pwm_signal, voltage):
|
| 34 |
+
# Simulate storing data using infrared voltage energy
|
| 35 |
+
stored_signal = pwm_signal * voltage
|
| 36 |
+
return stored_signal
|
| 37 |
+
|
| 38 |
+
# Directional Transmission (simulating by a shift in phase)
|
| 39 |
+
def directional_transmission(stored_signal, phase_shift):
|
| 40 |
+
# Apply a phase shift to simulate transmission towards a given direction
|
| 41 |
+
transmitted_signal = np.roll(stored_signal, phase_shift)
|
| 42 |
+
return transmitted_signal
|
| 43 |
+
|
| 44 |
+
# Create a time array
|
| 45 |
+
time = np.linspace(0, 1, time_steps)
|
| 46 |
+
|
| 47 |
+
# Generate SPWM Signal
|
| 48 |
+
spwm_signal = generate_spwm_signal(time, frequency, amplitude)
|
| 49 |
+
|
| 50 |
+
# Store the data using infrared voltage energy
|
| 51 |
+
infrared_stored_signal = infrared_storage(spwm_signal, infrared_voltage)
|
| 52 |
+
|
| 53 |
+
# Transmit the signal towards a given direction (simulate by shifting phase)
|
| 54 |
+
transmitted_signal = directional_transmission(infrared_stored_signal, phase_shift=100)
|
| 55 |
+
|
| 56 |
+
# Plot the SPWM signal, stored signal, and transmitted signal
|
| 57 |
+
plt.figure(figsize=(15, 8))
|
| 58 |
+
|
| 59 |
+
plt.subplot(3, 1, 1)
|
| 60 |
+
plt.plot(time, spwm_signal, color='blue', label='SPWM Signal')
|
| 61 |
+
plt.title('Sinusoidal Pulse Width Modulation (SPWM) Signal')
|
| 62 |
+
plt.xlabel('Time (s)')
|
| 63 |
+
plt.ylabel('Amplitude')
|
| 64 |
+
plt.grid(True)
|
| 65 |
+
plt.legend()
|
| 66 |
+
|
| 67 |
+
plt.subplot(3, 1, 2)
|
| 68 |
+
plt.plot(time, infrared_stored_signal, color='red', label='Infrared Stored Signal')
|
| 69 |
+
plt.title('Data Stored using Infrared Voltage Energy')
|
| 70 |
+
plt.xlabel('Time (s)')
|
| 71 |
+
plt.ylabel('Voltage')
|
| 72 |
+
plt.grid(True)
|
| 73 |
+
plt.legend()
|
| 74 |
+
|
| 75 |
+
plt.subplot(3, 1, 3)
|
| 76 |
+
plt.plot(time, transmitted_signal, color='green', label='Transmitted Signal')
|
| 77 |
+
plt.title('Transmitted Signal towards a Given Direction')
|
| 78 |
+
plt.xlabel('Time (s)')
|
| 79 |
+
plt.ylabel('Amplitude')
|
| 80 |
+
plt.grid(True)
|
| 81 |
+
plt.legend()
|
| 82 |
+
|
| 83 |
+
plt.tight_layout()
|
| 84 |
+
plt.show()
|
| 85 |
+
|
| 86 |
+
import torch
|
| 87 |
+
import torch.nn as nn
|
| 88 |
+
import numpy as np
|
| 89 |
+
import matplotlib.pyplot as plt
|
| 90 |
+
|
| 91 |
+
# Parameters
|
| 92 |
+
num_nodes = 100
|
| 93 |
+
time_steps = 1000 # Number of time steps for signal generation
|
| 94 |
+
frequency = 1 # Frequency of the sinusoidal wave (Hz)
|
| 95 |
+
amplitude = 1.0 # Amplitude of the sinusoidal wave
|
| 96 |
+
sampling_rate = 1000 # Samples per second
|
| 97 |
+
infrared_voltage = 0.7 # Simulated infrared voltage for storage
|
| 98 |
+
pulse_width_modulation_frequency = 50 # Frequency of PWM in Hz
|
| 99 |
+
attenuation_factor = 0.5 # Attenuation factor for signal traveling through dense space
|
| 100 |
+
noise_intensity = 0.2 # Intensity of noise to simulate interference
|
| 101 |
+
multi_path_delay = 50 # Delay for multi-path effect in number of samples
|
| 102 |
+
multi_path_amplitude = 0.3 # Amplitude of the delayed multi-path signal
|
| 103 |
+
|
| 104 |
+
# SPWM Signal Generation
|
| 105 |
+
def generate_spwm_signal(time, frequency, amplitude):
|
| 106 |
+
# Generate a sinusoidal signal
|
| 107 |
+
sine_wave = amplitude * np.sin(2 * np.pi * frequency * time)
|
| 108 |
+
# Generate PWM signal based on the sinusoidal signal
|
| 109 |
+
pwm_signal = np.where(sine_wave > np.random.rand(len(time)), 1, 0)
|
| 110 |
+
return pwm_signal
|
| 111 |
+
|
| 112 |
+
# Infrared Energy Storage
|
| 113 |
+
def infrared_storage(pwm_signal, voltage):
|
| 114 |
+
# Simulate storing data using infrared voltage energy
|
| 115 |
+
stored_signal = pwm_signal * voltage
|
| 116 |
+
return stored_signal
|
| 117 |
+
|
| 118 |
+
# Directional Transmission (simulating by a shift in phase)
|
| 119 |
+
def directional_transmission(stored_signal, phase_shift):
|
| 120 |
+
# Apply a phase shift to simulate transmission towards a given direction
|
| 121 |
+
transmitted_signal = np.roll(stored_signal, phase_shift)
|
| 122 |
+
return transmitted_signal
|
| 123 |
+
|
| 124 |
+
# Signal Attenuation in Dense Space
|
| 125 |
+
def attenuate_signal(signal, attenuation_factor):
|
| 126 |
+
# Apply exponential decay to simulate attenuation
|
| 127 |
+
attenuation = np.exp(-attenuation_factor * np.arange(len(signal)) / len(signal))
|
| 128 |
+
attenuated_signal = signal * attenuation
|
| 129 |
+
return attenuated_signal
|
| 130 |
+
|
| 131 |
+
# Add Noise to Simulate Interference
|
| 132 |
+
def add_noise(signal, noise_intensity):
|
| 133 |
+
noise = noise_intensity * np.random.randn(len(signal))
|
| 134 |
+
noisy_signal = signal + noise
|
| 135 |
+
return noisy_signal
|
| 136 |
+
|
| 137 |
+
# Apply Multi-Path Effects
|
| 138 |
+
def multi_path_effects(signal, delay, amplitude):
|
| 139 |
+
delayed_signal = np.roll(signal, delay) * amplitude
|
| 140 |
+
combined_signal = signal + delayed_signal
|
| 141 |
+
return combined_signal
|
| 142 |
+
|
| 143 |
+
# Create a time array
|
| 144 |
+
time = np.linspace(0, 1, time_steps)
|
| 145 |
+
|
| 146 |
+
# Generate SPWM Signal
|
| 147 |
+
spwm_signal = generate_spwm_signal(time, frequency, amplitude)
|
| 148 |
+
|
| 149 |
+
# Store the data using infrared voltage energy
|
| 150 |
+
infrared_stored_signal = infrared_storage(spwm_signal, infrared_voltage)
|
| 151 |
+
|
| 152 |
+
# Transmit the signal towards a given direction (simulate by shifting phase)
|
| 153 |
+
transmitted_signal = directional_transmission(infrared_stored_signal, phase_shift=100)
|
| 154 |
+
|
| 155 |
+
# Attenuate the signal in a densely populated space
|
| 156 |
+
attenuated_signal = attenuate_signal(transmitted_signal, attenuation_factor)
|
| 157 |
+
|
| 158 |
+
# Add noise to the signal
|
| 159 |
+
noisy_signal = add_noise(attenuated_signal, noise_intensity)
|
| 160 |
+
|
| 161 |
+
# Apply multi-path effects
|
| 162 |
+
final_signal = multi_path_effects(noisy_signal, multi_path_delay, multi_path_amplitude)
|
| 163 |
+
|
| 164 |
+
# Plot the SPWM signal, stored signal, transmitted signal, and final signal
|
| 165 |
+
plt.figure(figsize=(15, 12))
|
| 166 |
+
|
| 167 |
+
plt.subplot(4, 1, 1)
|
| 168 |
+
plt.plot(time, spwm_signal, color='blue', label='SPWM Signal')
|
| 169 |
+
plt.title('Sinusoidal Pulse Width Modulation (SPWM) Signal')
|
| 170 |
+
plt.xlabel('Time (s)')
|
| 171 |
+
plt.ylabel('Amplitude')
|
| 172 |
+
plt.grid(True)
|
| 173 |
+
plt.legend()
|
| 174 |
+
|
| 175 |
+
plt.subplot(4, 1, 2)
|
| 176 |
+
plt.plot(time, infrared_stored_signal, color='red', label='Infrared Stored Signal')
|
| 177 |
+
plt.title('Data Stored using Infrared Voltage Energy')
|
| 178 |
+
plt.xlabel('Time (s)')
|
| 179 |
+
plt.ylabel('Voltage')
|
| 180 |
+
plt.grid(True)
|
| 181 |
+
plt.legend()
|
| 182 |
+
|
| 183 |
+
plt.subplot(4, 1, 3)
|
| 184 |
+
plt.plot(time, transmitted_signal, color='green', label='Transmitted Signal')
|
| 185 |
+
plt.title('Transmitted Signal towards a Given Direction')
|
| 186 |
+
plt.xlabel('Time (s)')
|
| 187 |
+
plt.ylabel('Amplitude')
|
| 188 |
+
plt.grid(True)
|
| 189 |
+
plt.legend()
|
| 190 |
+
|
| 191 |
+
plt.subplot(4, 1, 4)
|
| 192 |
+
plt.plot(time, final_signal, color='purple', label='Final Signal with Attenuation, Noise, and Multi-Path Effects')
|
| 193 |
+
plt.title('Final Signal in Dense Space')
|
| 194 |
+
plt.xlabel('Time (s)')
|
| 195 |
+
plt.ylabel('Amplitude')
|
| 196 |
+
plt.grid(True)
|
| 197 |
+
plt.legend()
|
| 198 |
+
|
| 199 |
+
plt.tight_layout()
|
| 200 |
+
plt.show()
|
| 201 |
+
|
| 202 |
+
import torch
|
| 203 |
+
import torch.nn as nn
|
| 204 |
+
import numpy as np
|
| 205 |
+
import matplotlib.pyplot as plt
|
| 206 |
+
from matplotlib.animation import FuncAnimation
|
| 207 |
+
|
| 208 |
+
# Parameters
|
| 209 |
+
num_nodes = 100
|
| 210 |
+
time_steps = 1000 # Number of time steps for signal generation
|
| 211 |
+
frequency = 1 # Frequency of the sinusoidal wave (Hz)
|
| 212 |
+
amplitude = 1.0 # Amplitude of the sinusoidal wave
|
| 213 |
+
sampling_rate = 1000 # Samples per second
|
| 214 |
+
infrared_voltage = 0.7 # Simulated infrared voltage for storage
|
| 215 |
+
pulse_width_modulation_frequency = 50 # Frequency of PWM in Hz
|
| 216 |
+
attenuation_factor = 0.5 # Attenuation factor for signal traveling through dense space
|
| 217 |
+
noise_intensity = 0.2 # Intensity of noise to simulate interference
|
| 218 |
+
multi_path_delay = 50 # Delay for multi-path effect in number of samples
|
| 219 |
+
multi_path_amplitude = 0.3 # Amplitude of the delayed multi-path signal
|
| 220 |
+
|
| 221 |
+
# SPWM Signal Generation
|
| 222 |
+
def generate_spwm_signal(time, frequency, amplitude):
|
| 223 |
+
# Generate a sinusoidal signal
|
| 224 |
+
sine_wave = amplitude * np.sin(2 * np.pi * frequency * time)
|
| 225 |
+
# Generate PWM signal based on the sinusoidal signal
|
| 226 |
+
pwm_signal = np.where(sine_wave > np.random.rand(len(time)), 1, 0)
|
| 227 |
+
return pwm_signal
|
| 228 |
+
|
| 229 |
+
# Infrared Energy Storage
|
| 230 |
+
def infrared_storage(pwm_signal, voltage):
|
| 231 |
+
# Simulate storing data using infrared voltage energy
|
| 232 |
+
stored_signal = pwm_signal * voltage
|
| 233 |
+
return stored_signal
|
| 234 |
+
|
| 235 |
+
# Directional Transmission (simulating by a shift in phase)
|
| 236 |
+
def directional_transmission(stored_signal, phase_shift):
|
| 237 |
+
# Apply a phase shift to simulate transmission towards a given direction
|
| 238 |
+
transmitted_signal = np.roll(stored_signal, phase_shift)
|
| 239 |
+
return transmitted_signal
|
| 240 |
+
|
| 241 |
+
# Signal Attenuation in Dense Space
|
| 242 |
+
def attenuate_signal(signal, attenuation_factor):
|
| 243 |
+
# Apply exponential decay to simulate attenuation
|
| 244 |
+
attenuation = np.exp(-attenuation_factor * np.arange(len(signal)) / len(signal))
|
| 245 |
+
attenuated_signal = signal * attenuation
|
| 246 |
+
return attenuated_signal
|
| 247 |
+
|
| 248 |
+
# Add Noise to Simulate Interference
|
| 249 |
+
def add_noise(signal, noise_intensity):
|
| 250 |
+
noise = noise_intensity * np.random.randn(len(signal))
|
| 251 |
+
noisy_signal = signal + noise
|
| 252 |
+
return noisy_signal
|
| 253 |
+
|
| 254 |
+
# Apply Multi-Path Effects
|
| 255 |
+
def multi_path_effects(signal, delay, amplitude):
|
| 256 |
+
delayed_signal = np.roll(signal, delay) * amplitude
|
| 257 |
+
combined_signal = signal + delayed_signal
|
| 258 |
+
return combined_signal
|
| 259 |
+
|
| 260 |
+
# Create a time array
|
| 261 |
+
time = np.linspace(0, 1, time_steps)
|
| 262 |
+
|
| 263 |
+
# Generate SPWM Signal
|
| 264 |
+
spwm_signal = generate_spwm_signal(time, frequency, amplitude)
|
| 265 |
+
|
| 266 |
+
# Store the data using infrared voltage energy
|
| 267 |
+
infrared_stored_signal = infrared_storage(spwm_signal, infrared_voltage)
|
| 268 |
+
|
| 269 |
+
# Transmit the signal towards a given direction (simulate by shifting phase)
|
| 270 |
+
transmitted_signal = directional_transmission(infrared_stored_signal, phase_shift=100)
|
| 271 |
+
|
| 272 |
+
# Attenuate the signal in a densely populated space
|
| 273 |
+
attenuated_signal = attenuate_signal(transmitted_signal, attenuation_factor)
|
| 274 |
+
|
| 275 |
+
# Add noise to the signal
|
| 276 |
+
noisy_signal = add_noise(attenuated_signal, noise_intensity)
|
| 277 |
+
|
| 278 |
+
# Apply multi-path effects
|
| 279 |
+
final_signal = multi_path_effects(noisy_signal, multi_path_delay, multi_path_amplitude)
|
| 280 |
+
|
| 281 |
+
# Plot the animated signal
|
| 282 |
+
fig, ax = plt.subplots(figsize=(15, 6))
|
| 283 |
+
line, = ax.plot([], [], color='purple')
|
| 284 |
+
ax.set_xlim(0, time_steps)
|
| 285 |
+
ax.set_ylim(-1.5, 1.5)
|
| 286 |
+
ax.set_title('Animated Signal Transmission')
|
| 287 |
+
ax.set_xlabel('Time Step')
|
| 288 |
+
ax.set_ylabel('Amplitude')
|
| 289 |
+
ax.grid(True)
|
| 290 |
+
|
| 291 |
+
# Animation function to update the frame
|
| 292 |
+
def animate(frame):
|
| 293 |
+
# Update the signal to show propagation over time
|
| 294 |
+
current_signal = np.roll(final_signal, frame)
|
| 295 |
+
line.set_data(np.arange(len(current_signal)), current_signal)
|
| 296 |
+
return line,
|
| 297 |
+
|
| 298 |
+
# Create the animation
|
| 299 |
+
ani = FuncAnimation(fig, animate, frames=time_steps, interval=20, blit=True)
|
| 300 |
+
|
| 301 |
+
# Show the animation
|
| 302 |
+
plt.show()
|
| 303 |
+
|
| 304 |
+
import torch
|
| 305 |
+
import torch.nn as nn
|
| 306 |
+
import numpy as np
|
| 307 |
+
import matplotlib.pyplot as plt
|
| 308 |
+
from matplotlib.animation import FuncAnimation
|
| 309 |
+
|
| 310 |
+
# Parameters
|
| 311 |
+
num_nodes = 100
|
| 312 |
+
time_steps = 1000 # Number of time steps for signal generation
|
| 313 |
+
frequency = 1 # Frequency of the sinusoidal wave (Hz)
|
| 314 |
+
amplitude = 1.0 # Amplitude of the sinusoidal wave
|
| 315 |
+
sampling_rate = 1000 # Samples per second
|
| 316 |
+
infrared_voltage = 0.7 # Simulated infrared voltage for storage
|
| 317 |
+
pulse_width_modulation_frequency = 50 # Frequency of PWM in Hz
|
| 318 |
+
attenuation_factor = 0.5 # Attenuation factor for signal traveling through dense space
|
| 319 |
+
noise_intensity = 0.2 # Intensity of noise to simulate interference
|
| 320 |
+
multi_path_delay = 50 # Delay for multi-path effect in number of samples
|
| 321 |
+
multi_path_amplitude = 0.3 # Amplitude of the delayed multi-path signal
|
| 322 |
+
|
| 323 |
+
# Encryption parameters
|
| 324 |
+
encryption_keys = [0.5, 1.2, 0.9] # Different keys for multi-layered encryption
|
| 325 |
+
|
| 326 |
+
# SPWM Signal Generation
|
| 327 |
+
def generate_spwm_signal(time, frequency, amplitude):
|
| 328 |
+
# Generate a sinusoidal signal
|
| 329 |
+
sine_wave = amplitude * np.sin(2 * np.pi * frequency * time)
|
| 330 |
+
# Generate PWM signal based on the sinusoidal signal
|
| 331 |
+
pwm_signal = np.where(sine_wave > np.random.rand(len(time)), 1, 0)
|
| 332 |
+
return pwm_signal
|
| 333 |
+
|
| 334 |
+
# Infrared Energy Storage
|
| 335 |
+
def infrared_storage(pwm_signal, voltage):
|
| 336 |
+
# Simulate storing data using infrared voltage energy
|
| 337 |
+
stored_signal = pwm_signal * voltage
|
| 338 |
+
return stored_signal
|
| 339 |
+
|
| 340 |
+
# Directional Transmission (simulating by a shift in phase)
|
| 341 |
+
def directional_transmission(stored_signal, phase_shift):
|
| 342 |
+
# Apply a phase shift to simulate transmission towards a given direction
|
| 343 |
+
transmitted_signal = np.roll(stored_signal, phase_shift)
|
| 344 |
+
return transmitted_signal
|
| 345 |
+
|
| 346 |
+
# Signal Attenuation in Dense Space
|
| 347 |
+
def attenuate_signal(signal, attenuation_factor):
|
| 348 |
+
# Apply exponential decay to simulate attenuation
|
| 349 |
+
attenuation = np.exp(-attenuation_factor * np.arange(len(signal)) / len(signal))
|
| 350 |
+
attenuated_signal = signal * attenuation
|
| 351 |
+
return attenuated_signal
|
| 352 |
+
|
| 353 |
+
# Add Noise to Simulate Interference
|
| 354 |
+
def add_noise(signal, noise_intensity):
|
| 355 |
+
noise = noise_intensity * np.random.randn(len(signal))
|
| 356 |
+
noisy_signal = signal + noise
|
| 357 |
+
return noisy_signal
|
| 358 |
+
|
| 359 |
+
# Apply Multi-Path Effects
|
| 360 |
+
def multi_path_effects(signal, delay, amplitude):
|
| 361 |
+
delayed_signal = np.roll(signal, delay) * amplitude
|
| 362 |
+
combined_signal = signal + delayed_signal
|
| 363 |
+
return combined_signal
|
| 364 |
+
|
| 365 |
+
# Layered Encryption
|
| 366 |
+
def layered_encryption(signal, keys):
|
| 367 |
+
encrypted_signal = signal.copy()
|
| 368 |
+
for key in keys:
|
| 369 |
+
encrypted_signal = np.sin(encrypted_signal * key) # Encrypting layer
|
| 370 |
+
return encrypted_signal
|
| 371 |
+
|
| 372 |
+
# Layered Decryption
|
| 373 |
+
def layered_decryption(encrypted_signal, keys):
|
| 374 |
+
decrypted_signal = encrypted_signal.copy()
|
| 375 |
+
for key in reversed(keys):
|
| 376 |
+
decrypted_signal = np.arcsin(decrypted_signal) / key # Decrypting layer
|
| 377 |
+
return decrypted_signal
|
| 378 |
+
|
| 379 |
+
# Create a time array
|
| 380 |
+
time = np.linspace(0, 1, time_steps)
|
| 381 |
+
|
| 382 |
+
# Generate SPWM Signal
|
| 383 |
+
spwm_signal = generate_spwm_signal(time, frequency, amplitude)
|
| 384 |
+
|
| 385 |
+
# Store the data using infrared voltage energy
|
| 386 |
+
infrared_stored_signal = infrared_storage(spwm_signal, infrared_voltage)
|
| 387 |
+
|
| 388 |
+
# Transmit the signal towards a given direction (simulate by shifting phase)
|
| 389 |
+
transmitted_signal = directional_transmission(infrared_stored_signal, phase_shift=100)
|
| 390 |
+
|
| 391 |
+
# Attenuate the signal in a densely populated space
|
| 392 |
+
attenuated_signal = attenuate_signal(transmitted_signal, attenuation_factor)
|
| 393 |
+
|
| 394 |
+
# Add noise to the signal
|
| 395 |
+
noisy_signal = add_noise(attenuated_signal, noise_intensity)
|
| 396 |
+
|
| 397 |
+
# Apply multi-path effects
|
| 398 |
+
final_signal = multi_path_effects(noisy_signal, multi_path_delay, multi_path_amplitude)
|
| 399 |
+
|
| 400 |
+
# Encrypt the final signal with layered VPN-like encryption
|
| 401 |
+
encrypted_signal = layered_encryption(final_signal, encryption_keys)
|
| 402 |
+
|
| 403 |
+
# Decrypt the signal for verification
|
| 404 |
+
decrypted_signal = layered_decryption(encrypted_signal, encryption_keys)
|
| 405 |
+
|
| 406 |
+
# Plot the encrypted signal and decrypted signal
|
| 407 |
+
fig, ax = plt.subplots(2, 1, figsize=(15, 12))
|
| 408 |
+
|
| 409 |
+
# Plot Encrypted Signal
|
| 410 |
+
ax[0].plot(np.arange(len(encrypted_signal)), encrypted_signal, color='purple')
|
| 411 |
+
ax[0].set_title('Encrypted Signal w/Layered VPN Protection')
|
| 412 |
+
ax[0].set_xlabel('Time Step')
|
| 413 |
+
ax[0].set_ylabel('Amplitude')
|
| 414 |
+
ax[0].grid(True)
|
| 415 |
+
|
| 416 |
+
# Plot Decrypted Signal
|
| 417 |
+
ax[1].plot(np.arange(len(decrypted_signal)), decrypted_signal, color='green')
|
| 418 |
+
ax[1].set_title('Decrypted Signal w/Layered VPN Decryption')
|
| 419 |
+
ax[1].set_xlabel('Time Step')
|
| 420 |
+
ax[1].set_ylabel('Amplitude')
|
| 421 |
+
ax[1].grid(True)
|
| 422 |
+
|
| 423 |
+
plt.tight_layout()
|
| 424 |
+
plt.show()
|
| 425 |
+
|
| 426 |
+
import torch
|
| 427 |
+
import torch.nn as nn
|
| 428 |
+
import numpy as np
|
| 429 |
+
import matplotlib.pyplot as plt
|
| 430 |
+
from matplotlib.animation import FuncAnimation
|
| 431 |
+
|
| 432 |
+
# Parameters
|
| 433 |
+
num_nodes = 100
|
| 434 |
+
time_steps = 1000 # Number of time steps for signal generation
|
| 435 |
+
frequency = 1 # Frequency of the sinusoidal wave (Hz)
|
| 436 |
+
amplitude = 1.0 # Amplitude of the sinusoidal wave
|
| 437 |
+
sampling_rate = 1000 # Samples per second
|
| 438 |
+
infrared_voltage = 0.7 # Simulated infrared voltage for storage
|
| 439 |
+
pulse_width_modulation_frequency = 50 # Frequency of PWM in Hz
|
| 440 |
+
attenuation_factor = 0.5 # Attenuation factor for signal traveling through dense space
|
| 441 |
+
noise_intensity = 0.2 # Intensity of noise to simulate interference
|
| 442 |
+
multi_path_delay = 50 # Delay for multi-path effect in number of samples
|
| 443 |
+
multi_path_amplitude = 0.3 # Amplitude of the delayed multi-path signal
|
| 444 |
+
|
| 445 |
+
# Encryption parameters
|
| 446 |
+
encryption_keys = [0.5, 1.2, 0.9] # Different keys for multi-layered encryption
|
| 447 |
+
|
| 448 |
+
# SPWM Signal Generation
|
| 449 |
+
def generate_spwm_signal(time, frequency, amplitude):
|
| 450 |
+
# Generate a sinusoidal signal
|
| 451 |
+
sine_wave = amplitude * np.sin(2 * np.pi * frequency * time)
|
| 452 |
+
# Generate PWM signal based on the sinusoidal signal
|
| 453 |
+
pwm_signal = np.where(sine_wave > np.random.rand(len(time)), 1, 0)
|
| 454 |
+
return pwm_signal
|
| 455 |
+
|
| 456 |
+
# Infrared Energy Storage
|
| 457 |
+
def infrared_storage(pwm_signal, voltage):
|
| 458 |
+
# Simulate storing data using infrared voltage energy
|
| 459 |
+
stored_signal = pwm_signal * voltage
|
| 460 |
+
return stored_signal
|
| 461 |
+
|
| 462 |
+
# Directional Transmission (simulating by a shift in phase)
|
| 463 |
+
def directional_transmission(stored_signal, phase_shift):
|
| 464 |
+
# Apply a phase shift to simulate transmission towards a given direction
|
| 465 |
+
transmitted_signal = np.roll(stored_signal, phase_shift)
|
| 466 |
+
return transmitted_signal
|
| 467 |
+
|
| 468 |
+
# Signal Attenuation in Dense Space
|
| 469 |
+
def attenuate_signal(signal, attenuation_factor):
|
| 470 |
+
# Apply exponential decay to simulate attenuation
|
| 471 |
+
attenuation = np.exp(-attenuation_factor * np.arange(len(signal)) / len(signal))
|
| 472 |
+
attenuated_signal = signal * attenuation
|
| 473 |
+
return attenuated_signal
|
| 474 |
+
|
| 475 |
+
# Add Noise to Simulate Interference
|
| 476 |
+
def add_noise(signal, noise_intensity):
|
| 477 |
+
noise = noise_intensity * np.random.randn(len(signal))
|
| 478 |
+
noisy_signal = signal + noise
|
| 479 |
+
return noisy_signal
|
| 480 |
+
|
| 481 |
+
# Apply Multi-Path Effects
|
| 482 |
+
def multi_path_effects(signal, delay, amplitude):
|
| 483 |
+
delayed_signal = np.roll(signal, delay) * amplitude
|
| 484 |
+
combined_signal = signal + delayed_signal
|
| 485 |
+
return combined_signal
|
| 486 |
+
|
| 487 |
+
# Layered Encryption
|
| 488 |
+
def layered_encryption(signal, keys):
|
| 489 |
+
encrypted_signal = signal.copy()
|
| 490 |
+
for key in keys:
|
| 491 |
+
encrypted_signal = np.sin(encrypted_signal * key) # Encrypting layer
|
| 492 |
+
return encrypted_signal
|
| 493 |
+
|
| 494 |
+
# Layered Decryption
|
| 495 |
+
def layered_decryption(encrypted_signal, keys):
|
| 496 |
+
decrypted_signal = encrypted_signal.copy()
|
| 497 |
+
for key in reversed(keys):
|
| 498 |
+
decrypted_signal = np.arcsin(decrypted_signal) / key # Decrypting layer
|
| 499 |
+
return decrypted_signal
|
| 500 |
+
|
| 501 |
+
# Create a time array
|
| 502 |
+
time = np.linspace(0, 1, time_steps)
|
| 503 |
+
|
| 504 |
+
# Generate SPWM Signal
|
| 505 |
+
def generate_spwm_signal(time, frequency, amplitude):
|
| 506 |
+
sine_wave = amplitude * np.sin(2 * np.pi * frequency * time)
|
| 507 |
+
threshold = np.mean(sine_wave) # Use mean of sine wave as threshold
|
| 508 |
+
pwm_signal = np.where(sine_wave > threshold, 1, 0)
|
| 509 |
+
return pwm_signal
|
| 510 |
+
|
| 511 |
+
# Store the data using infrared voltage energy
|
| 512 |
+
infrared_stored_signal = infrared_storage(spwm_signal, infrared_voltage)
|
| 513 |
+
|
| 514 |
+
# Transmit the signal towards a given direction (simulate by shifting phase)
|
| 515 |
+
transmitted_signal = directional_transmission(infrared_stored_signal, phase_shift=100)
|
| 516 |
+
|
| 517 |
+
# Attenuate the signal in a densely populated space
|
| 518 |
+
attenuated_signal = attenuate_signal(transmitted_signal, attenuation_factor)
|
| 519 |
+
|
| 520 |
+
# Add noise to the signal
|
| 521 |
+
noisy_signal = add_noise(attenuated_signal, noise_intensity)
|
| 522 |
+
|
| 523 |
+
# Apply multi-path effects
|
| 524 |
+
final_signal = multi_path_effects(noisy_signal, multi_path_delay, multi_path_amplitude)
|
| 525 |
+
|
| 526 |
+
# Encrypt the final signal with layered VPN-like encryption
|
| 527 |
+
encrypted_signal = layered_encryption(final_signal, encryption_keys)
|
| 528 |
+
|
| 529 |
+
# Decrypt the signal for verification
|
| 530 |
+
decrypted_signal = layered_decryption(encrypted_signal, encryption_keys)
|
| 531 |
+
|
| 532 |
+
# Plot the encrypted signal and decrypted signal
|
| 533 |
+
fig, ax = plt.subplots(2, 1, figsize=(15, 12))
|
| 534 |
+
|
| 535 |
+
# Plot Encrypted Signal
|
| 536 |
+
ax[0].plot(np.arange(len(encrypted_signal)), encrypted_signal, color='purple')
|
| 537 |
+
ax[0].set_title('Encrypted Signal w/Layered VPN Protection')
|
| 538 |
+
ax[0].set_xlabel('Time Step')
|
| 539 |
+
ax[0].set_ylabel('Amplitude')
|
| 540 |
+
ax[0].grid(True)
|
| 541 |
+
|
| 542 |
+
# Plot Decrypted Signal
|
| 543 |
+
ax[1].plot(np.arange(len(decrypted_signal)), decrypted_signal, color='green')
|
| 544 |
+
ax[1].set_title('Decrypted Signal w/Layered VPN Decryption')
|
| 545 |
+
ax[1].set_xlabel('Time Step')
|
| 546 |
+
ax[1].set_ylabel('Amplitude')
|
| 547 |
+
ax[1].grid(True)
|
| 548 |
+
|
| 549 |
+
plt.tight_layout()
|
| 550 |
+
plt.show()
|
| 551 |
+
|
| 552 |
+
import torch
|
| 553 |
+
import torch.nn as nn
|
| 554 |
+
import numpy as np
|
| 555 |
+
import matplotlib.pyplot as plt
|
| 556 |
+
from matplotlib.animation import FuncAnimation
|
| 557 |
+
|
| 558 |
+
# Parameters
|
| 559 |
+
num_nodes = 100
|
| 560 |
+
time_steps = 1000 # Number of time steps for signal generation
|
| 561 |
+
frequency = 1 # Frequency of the sinusoidal wave (Hz)
|
| 562 |
+
amplitude = 1.0 # Amplitude of the sinusoidal wave
|
| 563 |
+
sampling_rate = 1000 # Samples per second
|
| 564 |
+
infrared_voltage = 0.7 # Simulated infrared voltage for storage
|
| 565 |
+
pulse_width_modulation_frequency = 50 # Frequency of PWM in Hz
|
| 566 |
+
attenuation_factor = 0.5 # Attenuation factor for signal traveling through dense space
|
| 567 |
+
noise_intensity = 0.2 # Intensity of noise to simulate interference
|
| 568 |
+
multi_path_delay = 50 # Delay for multi-path effect in number of samples
|
| 569 |
+
multi_path_amplitude = 0.3 # Amplitude of the delayed multi-path signal
|
| 570 |
+
|
| 571 |
+
# Encryption parameters
|
| 572 |
+
encryption_keys = [0.5, 1.2, 0.9] # Different keys for multi-layered encryption
|
| 573 |
+
|
| 574 |
+
# SPWM Signal Generation
|
| 575 |
+
def generate_spwm_signal(time, frequency, amplitude):
|
| 576 |
+
sine_wave = amplitude * np.sin(2 * np.pi * frequency * time)
|
| 577 |
+
threshold = np.mean(sine_wave) # Use mean of sine wave as threshold
|
| 578 |
+
pwm_signal = np.where(sine_wave > threshold, 1, 0)
|
| 579 |
+
return pwm_signal
|
| 580 |
+
|
| 581 |
+
# Infrared Energy Storage
|
| 582 |
+
def infrared_storage(pwm_signal, voltage):
|
| 583 |
+
# Simulate storing data using infrared voltage energy
|
| 584 |
+
stored_signal = pwm_signal * voltage
|
| 585 |
+
return stored_signal
|
| 586 |
+
|
| 587 |
+
# Directional Transmission (simulating by a shift in phase)
|
| 588 |
+
def directional_transmission(stored_signal, phase_shift):
|
| 589 |
+
# Apply a phase shift to simulate transmission towards a given direction
|
| 590 |
+
transmitted_signal = np.roll(stored_signal, phase_shift)
|
| 591 |
+
return transmitted_signal
|
| 592 |
+
|
| 593 |
+
# Signal Attenuation in Dense Space
|
| 594 |
+
def attenuate_signal(signal, attenuation_factor):
|
| 595 |
+
# Use a more accurate model for attenuation
|
| 596 |
+
attenuation = np.exp(-attenuation_factor * np.arange(len(signal)) / len(signal))
|
| 597 |
+
attenuated_signal = signal * attenuation
|
| 598 |
+
return attenuated_signal
|
| 599 |
+
|
| 600 |
+
# Add Noise to Simulate Interference
|
| 601 |
+
def add_noise(signal, noise_intensity):
|
| 602 |
+
noise = noise_intensity * np.random.randn(len(signal))
|
| 603 |
+
noisy_signal = signal + noise
|
| 604 |
+
return noisy_signal
|
| 605 |
+
|
| 606 |
+
# Apply Multi-Path Effects
|
| 607 |
+
def multi_path_effects(signal, delay, amplitude):
|
| 608 |
+
delayed_signal = np.roll(signal, delay) * amplitude
|
| 609 |
+
combined_signal = signal + delayed_signal
|
| 610 |
+
return combined_signal
|
| 611 |
+
|
| 612 |
+
# Layered Encryption
|
| 613 |
+
def layered_encryption(signal, keys):
|
| 614 |
+
encrypted_signal = signal.copy()
|
| 615 |
+
for key in keys:
|
| 616 |
+
encrypted_signal = np.sin(encrypted_signal * key) # Encrypting layer
|
| 617 |
+
return encrypted_signal
|
| 618 |
+
|
| 619 |
+
# Layered Decryption
|
| 620 |
+
def layered_decryption(encrypted_signal, keys):
|
| 621 |
+
decrypted_signal = encrypted_signal.copy()
|
| 622 |
+
for key in reversed(keys):
|
| 623 |
+
decrypted_signal = np.arcsin(decrypted_signal) / key # Decrypting layer
|
| 624 |
+
return decrypted_signal
|
| 625 |
+
|
| 626 |
+
# Validate encryption and decryption
|
| 627 |
+
def validate_encryption(original_signal, encrypted_signal, decrypted_signal):
|
| 628 |
+
assert np.allclose(original_signal, decrypted_signal, atol=1e-2), "Decryption failed to recover the original signal."
|
| 629 |
+
|
| 630 |
+
|
| 631 |
+
# Create a time array
|
| 632 |
+
time = np.linspace(0, 1, time_steps)
|
| 633 |
+
|
| 634 |
+
# Generate SPWM Signal
|
| 635 |
+
spwm_signal = generate_spwm_signal(time, frequency, amplitude)
|
| 636 |
+
|
| 637 |
+
# Store the data using infrared voltage energy
|
| 638 |
+
infrared_stored_signal = infrared_storage(spwm_signal, infrared_voltage)
|
| 639 |
+
|
| 640 |
+
# Transmit the signal towards a given direction (simulate by shifting phase)
|
| 641 |
+
transmitted_signal = directional_transmission(infrared_stored_signal, phase_shift=100)
|
| 642 |
+
|
| 643 |
+
# Attenuate the signal in a densely populated space
|
| 644 |
+
attenuated_signal = attenuate_signal(transmitted_signal, attenuation_factor)
|
| 645 |
+
|
| 646 |
+
# Add noise to the signal
|
| 647 |
+
noisy_signal = add_noise(attenuated_signal, noise_intensity)
|
| 648 |
+
|
| 649 |
+
# Apply multi-path effects
|
| 650 |
+
final_signal = multi_path_effects(noisy_signal, multi_path_delay, multi_path_amplitude)
|
| 651 |
+
|
| 652 |
+
# Encrypt the final signal with layered VPN-like encryption
|
| 653 |
+
encrypted_signal = layered_encryption(final_signal, encryption_keys)
|
| 654 |
+
|
| 655 |
+
# Decrypt the signal for verification
|
| 656 |
+
decrypted_signal = layered_decryption(encrypted_signal, encryption_keys)
|
| 657 |
+
|
| 658 |
+
# Plot the encrypted signal and decrypted signal
|
| 659 |
+
fig, ax = plt.subplots(2, 1, figsize=(15, 12))
|
| 660 |
+
|
| 661 |
+
# Plot Encrypted Signal
|
| 662 |
+
ax[0].plot(np.arange(len(encrypted_signal)), encrypted_signal, color='purple')
|
| 663 |
+
ax[0].set_title('Encrypted Signal w/Layered VPN Protection')
|
| 664 |
+
ax[0].set_xlabel('Time Step')
|
| 665 |
+
ax[0].set_ylabel('Amplitude')
|
| 666 |
+
ax[0].grid(True)
|
| 667 |
+
|
| 668 |
+
# Plot Decrypted Signal
|
| 669 |
+
ax[1].plot(np.arange(len(decrypted_signal)), decrypted_signal, color='green')
|
| 670 |
+
ax[1].set_title('Decrypted Signal w/Layered VPN Decryption')
|
| 671 |
+
ax[1].set_xlabel('Time Step')
|
| 672 |
+
ax[1].set_ylabel('Amplitude')
|
| 673 |
+
ax[1].grid(True)
|
| 674 |
+
|
| 675 |
+
plt.tight_layout()
|
| 676 |
+
plt.show()
|
| 677 |
+
|
| 678 |
+
import matplotlib.pyplot as plt
|
| 679 |
+
import numpy as np
|
| 680 |
+
|
| 681 |
+
# Function to create a gradient color effect
|
| 682 |
+
def gradient_color(signal, cmap='viridis'):
|
| 683 |
+
norm = plt.Normalize(signal.min(), signal.max())
|
| 684 |
+
colors = plt.get_cmap(cmap)(norm(signal))
|
| 685 |
+
return colors
|
| 686 |
+
|
| 687 |
+
# Create a time array
|
| 688 |
+
time = np.arange(len(final_signal))
|
| 689 |
+
|
| 690 |
+
# Generate gradient colors based on final signal
|
| 691 |
+
colors = gradient_color(final_signal)
|
| 692 |
+
|
| 693 |
+
# Plot the final signal with reflection effect
|
| 694 |
+
fig, ax = plt.subplots(figsize=(15, 6))
|
| 695 |
+
|
| 696 |
+
# Plot the final signal
|
| 697 |
+
ax.plot(time, final_signal, color='blue', label='Final Signal')
|
| 698 |
+
|
| 699 |
+
# Add reflection effect
|
| 700 |
+
reflection_factor = 0.3
|
| 701 |
+
reflection = final_signal * reflection_factor
|
| 702 |
+
reflection_color = 'lightblue'
|
| 703 |
+
|
| 704 |
+
# Plot the reflection
|
| 705 |
+
ax.plot(time, -reflection - reflection.min(), color=reflection_color, linestyle='--', alpha=0.6, label='Signal Reflection')
|
| 706 |
+
|
| 707 |
+
# Add color gradient
|
| 708 |
+
for i in range(len(final_signal) - 1):
|
| 709 |
+
ax.plot(time[i:i+2], final_signal[i:i+2], color=colors[i], lw=2)
|
| 710 |
+
|
| 711 |
+
# Enhance the plot
|
| 712 |
+
ax.set_title('Final Signal with Reflection and Color Gradient')
|
| 713 |
+
ax.set_xlabel('Time Step')
|
| 714 |
+
ax.set_ylabel('Amplitude')
|
| 715 |
+
ax.legend()
|
| 716 |
+
ax.grid(True)
|
| 717 |
+
|
| 718 |
+
plt.show()
|
| 719 |
+
|
| 720 |
+
import matplotlib.pyplot as plt
|
| 721 |
+
import numpy as np
|
| 722 |
+
import matplotlib.colors as mcolors
|
| 723 |
+
|
| 724 |
+
# Function to create a gradient color effect
|
| 725 |
+
def gradient_color(signal, cmap='viridis'):
|
| 726 |
+
norm = plt.Normalize(signal.min(), signal.max())
|
| 727 |
+
colors = plt.get_cmap(cmap)(norm(signal))
|
| 728 |
+
return colors
|
| 729 |
+
|
| 730 |
+
# Create a time array
|
| 731 |
+
time = np.arange(len(final_signal))
|
| 732 |
+
|
| 733 |
+
# Generate gradient colors based on final signal
|
| 734 |
+
colors = gradient_color(final_signal)
|
| 735 |
+
|
| 736 |
+
# Plot the final signal with reflection effect
|
| 737 |
+
fig, ax = plt.subplots(figsize=(15, 6))
|
| 738 |
+
|
| 739 |
+
# Create a smooth line plot with color transitions
|
| 740 |
+
for i in range(len(final_signal) - 1):
|
| 741 |
+
ax.plot(time[i:i+2], final_signal[i:i+2], color=colors[i], lw=2)
|
| 742 |
+
|
| 743 |
+
# Add the final signal plot
|
| 744 |
+
ax.plot(time, final_signal, color='blue', alpha=0.5, label='Final Signal')
|
| 745 |
+
|
| 746 |
+
# Add reflection effect
|
| 747 |
+
reflection_factor = 0.3
|
| 748 |
+
reflection = final_signal * reflection_factor
|
| 749 |
+
reflection_color = 'lightblue'
|
| 750 |
+
|
| 751 |
+
# Plot the reflection
|
| 752 |
+
ax.plot(time, -reflection - reflection.min(), color=reflection_color, linestyle='--', alpha=0.6, label='Signal Reflection')
|
| 753 |
+
|
| 754 |
+
# Enhance the plot
|
| 755 |
+
ax.set_title('Demo')
|
| 756 |
+
ax.set_xlabel('Time Step')
|
| 757 |
+
ax.set_ylabel('Amplitude')
|
| 758 |
+
ax.legend()
|
| 759 |
+
ax.grid(True)
|
| 760 |
+
|
| 761 |
+
plt.show()
|