simulation

Lennard-Jones potential simulation

泄露秘密 提交于 2019-12-24 15:56:26
问题 import pygame import random import numpy as np import matplotlib.pyplot as plt import math number_of_particles = 70 my_particles = [] background_colour = (255,255,255) width, height = 500, 500 sigma = 1 e = 1 dt = 0.1 v = 0 a = 0 r = 1 def r(p1,p2): dx = p1.x - p2.x dy = p1.y - p2.y angle = 0.5 * math.pi - math.atan2(dy, dx) dist = np.hypot(dx, dy) return dist def collide(p1, p2): dx = p1.x - p2.x dy = p1.y - p2.y dist = np.hypot(dx, dy) if dist < (p1.size + p2.size): tangent = math.atan2(dy,

Which file to extend for customized messages in veins? What is the purpose of AirFrame11p.msg?

大城市里の小女人 提交于 2019-12-24 14:43:00
问题 I'm new to SUMO, Veins, OMNET++ and simulations with a bit background of networks. I have successfully setup environment and run veins 4.6 demo application. On google found that unlike RSU, Car modules are added on the fly. In demo example car nodes send Airframe11p message, i'm not getting where this message is being populated because in TraCIDemo11p.cc methods (onWSA, onWSM, handleSelfMsg, handlePositionUpdate) we are dealing with WSM message types and BaseWaveApplLayer::checkAndTrackPacket

How to simulate mouse click in a Directx game

早过忘川 提交于 2019-12-24 13:26:23
问题 I have a game written in Directx (not mine it's mmo game). The game window isn't active (not minimized, just it's behind other windows but if is possible it can be minimized also). I want to simulate mouse click on x, y position. Spy++ doesn't show anything in message when i'm clicking in game. For now i did just that: private void start_Click(object sender, EventArgs e) { IntPtr ActualWindow = GetActiveWindow(); ShowWindow(hWnd, ShowWindowCommands.Restore); //show game window Thread.Sleep(50

modem.oqpskmod for BER

爷,独闯天下 提交于 2019-12-24 12:10:05
问题 hi can anyone show how to use the modem.oqpskmod for BER. thanks! h = modem.oqpskmod y = modulate(h, values); g = modem.oqpskdemod(h) z = demodulate(g, y) let's assume that i have array called values which contains only 1s and 0s. my question is how would i calculate BER? of course if above my code is correct. 回答1: Based on this Wikipedia page, you simply have to compute the number of incorrect bits and divide by the total number of transferred bits to get the bit error rate (BER). If values

How can I compute the distance between two patches?

三世轮回 提交于 2019-12-24 12:04:47
问题 I need to find the minimum distance between patches in front of my agent to a certain patch (goal), in order to select the patch that would create the most optimal (shortest) path. The primitive distance only requires one argument so I can't use it as is for this function. 回答1: The distance primitive only requires one argument, yes, but it is a "patch or turtle primitive": it must be run in the context of a particular agent by "asking" it for its distance to another, so you can think of the

Generate two categorical variables with a chosen degree of association in R

可紊 提交于 2019-12-24 11:43:56
问题 I'd like to use R to generate two categorical variables (such as eye color and hair color, for instance) where I can specify the degree to which these two variables are associated. It doesn't really matter to me which levels of eye color would be associated with which levels of hair color, but just being able to specify an overall association, such as by specifying the odds ratio, is a requirement. Also, I know there are ways to do this for two normally distributed continuous variables using,

Problems with strings and fstream

Deadly 提交于 2019-12-24 10:47:51
问题 I'm currently working on a project where I need to implement several classes to simulate a cafeteria. Each "student" who is waiting on line to get their food has 5 variables which describe them, that is: name, group, entree type, snack/dessert type, and a number representing the amount of salad they plan on buying in ounces. The idea is that all this information will be read in using fstream from a text file (with the outline following a specific order and repeating for each student). Once

C++ Simulate sequence of pulse trains

半腔热情 提交于 2019-12-24 08:26:20
问题 I'm trying to model a pulse waveform in my application and I need a way to keep track of the pulses so that I can repeat their sequence. From the figure shown below, what I'd like to do is simulate the first three pulses (pulse 1-3), then simulate pulse 4 immediately after pulse 3, and simulate pulse 5 immediately after 4. Then repeat the whole sequence N times. As shown in the diagram, I have the interval in seconds, the start time of the first pulse in seconds, and the duration of each

Monte Carlo simulation of correlation between two Brownian motion (continuous random walk)

若如初见. 提交于 2019-12-24 08:15:17
问题 y <- cumsum(rnorm(100,0,1)) # random normal, with small (1.0) drift. y.ts <- ts(y) x <- cumsum(rnorm(100,0,1)) x x.ts <- ts(x) ts.plot(y.ts,ty= "l", x.ts) # plot the two random walks Regression.Q1 = lm(y~x) ; summary(lm2) summary(Regression.Q1) t.test1 <- (summary(Regression.Q1)$coef[2,3]) # T-test computation y[t] = y[t-1] + epsilon[t] epsilon[t] ~ N(0,1) set.seed(1) t=1000 epsilon=sample(c(-1,1), t, replace = 1) # Generate k random walks across time {0, 1, ... , T} N=T=1e3 y=t(apply(matrix

Manual simulation of Markov Chain in R (2)

六眼飞鱼酱① 提交于 2019-12-24 07:50:37
问题 Consider the Markov chain with state space S = {1, 2} , transition matrix and initial distribution α = (1/2, 1/2) . Simulate 5 steps of the Markov chain (that is, simulate X 0 , X 1 , . . . , X 5 ). Repeat the simulation 100 times. My solution: states <- c(1, 2) alpha <- c(1, 1)/2 mat <- matrix(c(1/2, 1/2, 0, 1), nrow = 2, ncol = 2) nextX <- function(X, pMat) { probVec <- vector() if(X == states[1]) { probVec <- pMat[1,] } if(X==states[2]) { probVec <- pMat[2,] } return(sample(states, 1,