simulation

Recording data in a long running python simulation

十年热恋 提交于 2019-12-02 10:02:36
I am running a simulation from which I need to record some small numpy arrays every cycle. My current solution is to load, write then save as follows: existing_data = np.load("existing_record.npy") updated = np.dstack((existing_data,new_array[...,None])) np.save("existing_record.npy",updated) This has created a big performance bottleneck and the simulation runs at half the speed with this method. I have considered appending the numpy arrays to a list and writing it at the end of the simulation but this could obviously lead to running out of ram or losing data in a crash etc. Are there any

OpenModelica modelling Coulomb friction: Translation Error, post-optimization module findZeroCrossings (simulation) failed

偶尔善良 提交于 2019-12-02 07:52:30
问题 I'm trying to simulate Coulomb friction in Modelica. The basic concept is to check if relative velocity speed between to surfaces is less than a constant and the external force which tried to slid surfaces against each other is less than maximum static friction force (normalForce * staticFrictionCoefficient) then the friction force is equal to negative of the external shear force. otherwise, the friction force is equal to the kinetic friction force (normalForce * kineticFrictionCoefficient)in

Feedback from threads to main program

梦想的初衷 提交于 2019-12-02 05:13:52
My software will simulate a few hundred hardware devices, each of which will send several thousand reports to a database server. Trying it without threading did not give very good results, so now it's time to thread. Since I am load testing the d/b server, some of those transactions will succeed and a few may fail. The GUI of the main program needs to reflect this. How should the threads communicate their results back to the main program? Update global variables? Send a message? Or something lese? Now, if I update only at the end of each thread then the GUI is going to look rather boring (and

Mass Ball-to-Ball Collision Handling (as in, lots of balls)

醉酒当歌 提交于 2019-12-01 21:53:10
问题 Update: Found out that I was using the radius as the diameter, which was why the mtd was overcompensating. Another Update: The reason my balls are overlapping seem to be because there's only one check for every collision. After some research, some are saying that one of the ways you could prevent overlapping with objects piling up is to recursively perform the collision check. This works to an extent, and I suspect that it'd work even better if the physics were a lot more accurate. I'll

Mass Ball-to-Ball Collision Handling (as in, lots of balls)

久未见 提交于 2019-12-01 20:30:49
Update: Found out that I was using the radius as the diameter, which was why the mtd was overcompensating. Another Update: The reason my balls are overlapping seem to be because there's only one check for every collision. After some research, some are saying that one of the ways you could prevent overlapping with objects piling up is to recursively perform the collision check. This works to an extent, and I suspect that it'd work even better if the physics were a lot more accurate. I'll update again if I find any more solutions. Also, I'm using Simucal's collision correction code. Hi,

Count the number of adjacent boxes

最后都变了- 提交于 2019-12-01 17:08:17
Suppose I have a set of (X,Y) coordinates of 1000 boxes. ( x1, y1) ( x2, y2) Area (0.0000,0.0000) (0.3412,0.4175) 0.1424 (0.7445,0.0000) (1.0000,0.6553) 0.1674 (0.7445,0.6553) (1.0000,1.0000) 0.0881 (0.0000,0.6553) (0.7445,1.0000) 0.2566 (0.3412,0.0000) (0.7445,0.4175) 0.1684 (0.3412,0.4175) (0.7445,0.6553) 0.0959 (0.0000,0.4175) (0.3412,0.6553) 0.0812 ....etc I would like to calculate the number of adjacent boxes for each of them using c/c++ . How can I do it? Example In this picture, the total number of adjacent boxes for box-7 is six, for box-3 is three. How can I count them using c++?

Calculating distance between cars nodes VEINS

会有一股神秘感。 提交于 2019-12-01 13:10:39
问题 I am new to VEINS and trying to implement weighted p-persistence inside MyVeinsApp.cc. Distance between the sending node and receiving is used in that formula. I saw the 2 functions below. virtual Coord& getSenderPos(); virtual const Coord& getSenderPos() const {return const_cast<WaveShortMessage*>(this)->getSenderPos();} Should I use one of those methods to calculate the distance between nodes? Please advise on the best approach. 回答1: For the distance you obviously need the two positions.

How make a list of cumulative sum in netlogo

折月煮酒 提交于 2019-12-01 00:46:11
How can i make a list of cumulative sum of a other list? i tried it that way: ;;all temperatrue-values around the turtle saved in list set temperature_values (list [(output-heat + 1)^ Freedom] of neighbors) ;;build cumulative value of temperatures and put each value in list let tempsum 0 set tempsum_list [] foreach temperature_values [set tempsum (tempsum + ? ) set tempsum_list fput tempsum tempsum_list ] but it doesn't work. can anyone fix this problem? it says that "+ excepted a input but gets a list instead". your code for a cumulative sum works (except that I think you need lput rather

Two-Phase Modelica Media example

╄→尐↘猪︶ㄣ 提交于 2019-11-30 23:25:56
I am trying to develop a simulation in OpenModelica of a flow that has a single substance that will be liquid or vapor. The Modelica.Media.Water models do have two phases, but are extremely complicated, and would be very hard to reproduce for a completely different substance. I would like to find a simple example of a two phase medium that I can work from. There is a partial package TemplateMedium and a partial package PartialTwoPhaseMedium, but I don't see any examples of how to write a completely new Medium that can be in either of two phase. If anyone can provide a simple example, or just a

end to end delay in Veins

余生长醉 提交于 2019-11-30 21:03:53
问题 I want to calculate end-to-end delay in Veins example scenario. I have already read old mails that are related to this topic but they don't provide a real solution for the problem. I used getCreationTime() and simTime() functions. The resulting delay is about 1.70*10^-4 . This delay doesn't make sense for me. It is supposed to be more. I need some help at this point. I take the creation time of macPkt by using mackPkt->creationTime() function and i extract simTime() from it for calculating