SlideShare uma empresa Scribd logo
1 de 18
Barnes-Hut Algorithm (TREECODE)
The Barnes–Hut simulation (Josh Barnes and Piet Hut) is an algorithm for performing
an n-body simulation. It is notable for having order O(n log n) compared to a direct-sum
algorithm which would be O(n2).
Berkembang dan sudah banyak digunakan dikasus N-body dan SPH
karena bisa di paralelisasi.
NOTE
The crucial idea in speeding up the brute force algorithm is to group nearby bodies and
approximate them as a single body. If the group is sufficiently far away, we can
approximate its gravitational effects by using its center of mass.
If two bodies have positions (x1 , y1) and (x2, y2), and masses m1 and m2, center of mass (x,
y) are given by:
m = m1 + m2
x = (x1.m1 + x2.m2) / m
y = (y1.m1 + y2.m2) / m
It recursively divides the set of bodies into
groups by storing them in a quad-tree (2D) or
Octree (3D),
recursively subdivided into quadrants until
each subdivision contains 0 or 1 bodies
To calculate the net force on a particular body, traverse the nodes of the tree, starting
from the root. If the center-of-mass of an internal node is sufficiently far from the body,
approximate the bodies contained in that part of the tree as a single body, whose
position is the group’s center of mass and whose mass is the group’s total mass. The
algorithm is fast because we don’t need to individually examine any of the bodies in the
group.
If the internal node is not sufficiently far from the body, recursively traverse each of its
subtrees.
To determine if a node is sufficiently far away, compute the quotient s / d,
s = width of the region represented by the internal node,
d = the distance between the body and the node’s center-of-mass.
Then, compare this ratio against a threshold value θ.
If s / d < θ, then the internal node is sufficiently far away.
By adjusting the θ parameter, we can change the speed and accuracy of the
simulation. We will always use θ = 0.5, a value commonly used in practice. Note that if
θ = 0, then no internal node is treated as a single body, and the algorithm degenerates
to brute force.
CONSTRUCTING THE BARNES-HUT TREE
To construct the Barnes-Hut tree, insert the bodies one after another. To insert a body
b into the tree rooted at node x, use the following recursive procedure:
1. If node x does not contain a body, put the new body b here.
2. If node x is an internal node, update the center-of-mass and total mass of x.
Recursively insert the body b in the appropriate quadrant.
3. If node x is an external node, say containing a body named c, then there are two
bodies b and c in the same region. Subdivide the region further by creating four
children. Then, recursively insert both b and c into the appropriate quadrant(s). Since
b and c may still end up in the same quadrant, there may be several subdivisions
during a single insertion. Finally, update the center-of-mass and total mass of x.
Example:
Every internal node contain the center of mass and total mass of their
bodies.
CALCULATING THE FORCE ACTING ON A BODY
To calculate the net force acting on body b, use the following recursive procedure,
starting with the root of the quad-tree:
1. If the current node is an external node (and it is not body b), calculate the force
exerted by the current node on b, and add this amount to b’s net force.
2. Otherwise, calculate the ratio s/d. If s/d < θ, treat this internal node as a single
body, and calculate the force it exerts on body b, and add this amount to b’s net
force.
3. Otherwise, run the procedure recursively on each of the current node’s children.
As an example, to calculate the net force acting on body a, we start at the root node,
which is an internal node. It represents the center-of-mass of the six bodies a, b, c, d,
e, and f, which have masses 1, 2, 3, 4, 5, and 6 kg, respectively.
Jika A terlalu jauh dari pusat massa sistem total (kriteria opening
angle terpenuhi) A akan di anggap terkena “gaya” dari sistem itu
sendiri (tidak perlu lagi menghitung per node internal).
Calculate Quadrapole moment (for b, c and d) if
it is included.
Referensi:
http://www.cs.princeton.edu/courses/archive/fall03/cs126/assignments/barnes-hut.html
http://arborjs.org/docs/barnes-hut
http://www.ifa.hawaii.edu/~barnes/treecode/treeguide.html
http://en.wikipedia.org/wiki/Barnes%E2%80%93Hut_simulation

Mais conteúdo relacionado

Mais procurados

Post_Number Systems_7
Post_Number Systems_7Post_Number Systems_7
Post_Number Systems_7Marc King
 
Vector fields and equipotentials
Vector fields and equipotentialsVector fields and equipotentials
Vector fields and equipotentialsTarun Gehlot
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mstSSE_AndyLi
 
George Green's Contribution to MRI, Roger Bowley, 21 October 2014
George Green's Contribution to MRI, Roger Bowley, 21 October 2014George Green's Contribution to MRI, Roger Bowley, 21 October 2014
George Green's Contribution to MRI, Roger Bowley, 21 October 2014uazkjs
 
Faktorisasi aljabar kelas 7
Faktorisasi aljabar kelas 7Faktorisasi aljabar kelas 7
Faktorisasi aljabar kelas 7Shofi D. 'Ulhaq
 
Binping xiao superconducting surface impedance under radiofrequency field
Binping xiao   superconducting surface impedance under radiofrequency fieldBinping xiao   superconducting surface impedance under radiofrequency field
Binping xiao superconducting surface impedance under radiofrequency fieldthinfilmsworkshop
 
Quantum Computation and the Stabilizer Formalism for Error Correction
Quantum Computation and the Stabilizer Formalism for Error CorrectionQuantum Computation and the Stabilizer Formalism for Error Correction
Quantum Computation and the Stabilizer Formalism for Error CorrectionDaniel Bulhosa Solórzano
 
Scribe Post 6
Scribe Post 6Scribe Post 6
Scribe Post 6MrSiwWy
 

Mais procurados (20)

Post_Number Systems_7
Post_Number Systems_7Post_Number Systems_7
Post_Number Systems_7
 
Physics Assignment Help
Physics Assignment Help Physics Assignment Help
Physics Assignment Help
 
Vector fields and equipotentials
Vector fields and equipotentialsVector fields and equipotentials
Vector fields and equipotentials
 
Calc 4.4b
Calc 4.4bCalc 4.4b
Calc 4.4b
 
15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst15 chapter9 graph_algorithms_mst
15 chapter9 graph_algorithms_mst
 
George Green's Contribution to MRI, Roger Bowley, 21 October 2014
George Green's Contribution to MRI, Roger Bowley, 21 October 2014George Green's Contribution to MRI, Roger Bowley, 21 October 2014
George Green's Contribution to MRI, Roger Bowley, 21 October 2014
 
Faktorisasi aljabar kelas 7
Faktorisasi aljabar kelas 7Faktorisasi aljabar kelas 7
Faktorisasi aljabar kelas 7
 
NAM_final2015
NAM_final2015NAM_final2015
NAM_final2015
 
Teorema de Green-Tao
Teorema de Green-TaoTeorema de Green-Tao
Teorema de Green-Tao
 
Mechanical Engineering Assignment Help
Mechanical Engineering Assignment HelpMechanical Engineering Assignment Help
Mechanical Engineering Assignment Help
 
17 prims-kruskals (1)
17 prims-kruskals (1)17 prims-kruskals (1)
17 prims-kruskals (1)
 
Lar calc10 ch02_sec4
Lar calc10 ch02_sec4Lar calc10 ch02_sec4
Lar calc10 ch02_sec4
 
Binping xiao superconducting surface impedance under radiofrequency field
Binping xiao   superconducting surface impedance under radiofrequency fieldBinping xiao   superconducting surface impedance under radiofrequency field
Binping xiao superconducting surface impedance under radiofrequency field
 
Ewald summation
Ewald summationEwald summation
Ewald summation
 
Serie de dyson
Serie de dysonSerie de dyson
Serie de dyson
 
Quantum Computation and the Stabilizer Formalism for Error Correction
Quantum Computation and the Stabilizer Formalism for Error CorrectionQuantum Computation and the Stabilizer Formalism for Error Correction
Quantum Computation and the Stabilizer Formalism for Error Correction
 
Gauge theory field
Gauge theory fieldGauge theory field
Gauge theory field
 
presentation_chalmers
presentation_chalmerspresentation_chalmers
presentation_chalmers
 
Presentation gauge field theory
Presentation gauge field theoryPresentation gauge field theory
Presentation gauge field theory
 
Scribe Post 6
Scribe Post 6Scribe Post 6
Scribe Post 6
 

Destaque

Binary-Search-Tree (BST) - Inserting a node into a BST
Binary-Search-Tree (BST) - Inserting a node into a BSTBinary-Search-Tree (BST) - Inserting a node into a BST
Binary-Search-Tree (BST) - Inserting a node into a BSTLuka Lopusina
 
Lecture 9: Binary tree basics
Lecture 9: Binary tree basicsLecture 9: Binary tree basics
Lecture 9: Binary tree basicsVivek Bhargav
 
Ch13 Binary Search Tree
Ch13 Binary Search TreeCh13 Binary Search Tree
Ch13 Binary Search Treeleminhvuong
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Lovelyn Rose
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 

Destaque (8)

Binary-Search-Tree (BST) - Inserting a node into a BST
Binary-Search-Tree (BST) - Inserting a node into a BSTBinary-Search-Tree (BST) - Inserting a node into a BST
Binary-Search-Tree (BST) - Inserting a node into a BST
 
Lecture 9: Binary tree basics
Lecture 9: Binary tree basicsLecture 9: Binary tree basics
Lecture 9: Binary tree basics
 
Ch13 Binary Search Tree
Ch13 Binary Search TreeCh13 Binary Search Tree
Ch13 Binary Search Tree
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
 
Trie Data Structure
Trie Data StructureTrie Data Structure
Trie Data Structure
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 

Semelhante a Tree Algorithm

Finite element method
Finite element methodFinite element method
Finite element methodMevada Maulik
 
DOMV No 4 PHYSICAL DYNAMIC MODEL TYPES (1).pdf
DOMV No 4  PHYSICAL DYNAMIC MODEL TYPES (1).pdfDOMV No 4  PHYSICAL DYNAMIC MODEL TYPES (1).pdf
DOMV No 4 PHYSICAL DYNAMIC MODEL TYPES (1).pdfahmedelsharkawy98
 
Enhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial DatasetEnhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial DatasetAlaaZ
 
Physical Chemistry Homework Help
Physical Chemistry Homework HelpPhysical Chemistry Homework Help
Physical Chemistry Homework HelpEdu Assignment Help
 
physics430_lecture06. center of mass, angular momentum
physics430_lecture06. center of mass, angular momentumphysics430_lecture06. center of mass, angular momentum
physics430_lecture06. center of mass, angular momentumMughuAlain
 
Optimization Of Fuzzy Bexa Using Nm
Optimization Of Fuzzy Bexa Using NmOptimization Of Fuzzy Bexa Using Nm
Optimization Of Fuzzy Bexa Using NmAshish Khetan
 
Free Ebooks Download ! Edhole.com
Free Ebooks Download ! Edhole.comFree Ebooks Download ! Edhole.com
Free Ebooks Download ! Edhole.comEdhole.com
 
11 - 3 Experiment 11 Simple Harmonic Motio.docx
11  -  3       Experiment 11 Simple Harmonic Motio.docx11  -  3       Experiment 11 Simple Harmonic Motio.docx
11 - 3 Experiment 11 Simple Harmonic Motio.docxtarifarmarie
 
centroid and centre of gravity...
centroid and centre of gravity...centroid and centre of gravity...
centroid and centre of gravity...Mihir Dixit
 
ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSfenil patel
 
1VectorAdditionofForcesObjectivesTousethe.docx
 1VectorAdditionofForcesObjectivesTousethe.docx 1VectorAdditionofForcesObjectivesTousethe.docx
1VectorAdditionofForcesObjectivesTousethe.docxShiraPrater50
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquerchidabdu
 
Boundness of a neural network weights using the notion of a limit of a sequence
Boundness of a neural network weights using the notion of a limit of a sequenceBoundness of a neural network weights using the notion of a limit of a sequence
Boundness of a neural network weights using the notion of a limit of a sequenceIJDKP
 

Semelhante a Tree Algorithm (20)

Finite element method
Finite element methodFinite element method
Finite element method
 
DOMV No 4 PHYSICAL DYNAMIC MODEL TYPES (1).pdf
DOMV No 4  PHYSICAL DYNAMIC MODEL TYPES (1).pdfDOMV No 4  PHYSICAL DYNAMIC MODEL TYPES (1).pdf
DOMV No 4 PHYSICAL DYNAMIC MODEL TYPES (1).pdf
 
Algorithm Exam Help
Algorithm Exam HelpAlgorithm Exam Help
Algorithm Exam Help
 
Enhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial DatasetEnhance The K Means Algorithm On Spatial Dataset
Enhance The K Means Algorithm On Spatial Dataset
 
Physical Chemistry Homework Help
Physical Chemistry Homework HelpPhysical Chemistry Homework Help
Physical Chemistry Homework Help
 
physics430_lecture06. center of mass, angular momentum
physics430_lecture06. center of mass, angular momentumphysics430_lecture06. center of mass, angular momentum
physics430_lecture06. center of mass, angular momentum
 
Optimization Of Fuzzy Bexa Using Nm
Optimization Of Fuzzy Bexa Using NmOptimization Of Fuzzy Bexa Using Nm
Optimization Of Fuzzy Bexa Using Nm
 
Free Ebooks Download ! Edhole.com
Free Ebooks Download ! Edhole.comFree Ebooks Download ! Edhole.com
Free Ebooks Download ! Edhole.com
 
Project report on Data Clustering
Project report on Data ClusteringProject report on Data Clustering
Project report on Data Clustering
 
Review
ReviewReview
Review
 
11 - 3 Experiment 11 Simple Harmonic Motio.docx
11  -  3       Experiment 11 Simple Harmonic Motio.docx11  -  3       Experiment 11 Simple Harmonic Motio.docx
11 - 3 Experiment 11 Simple Harmonic Motio.docx
 
Lec10
Lec10Lec10
Lec10
 
20120140503023
2012014050302320120140503023
20120140503023
 
centroid and centre of gravity...
centroid and centre of gravity...centroid and centre of gravity...
centroid and centre of gravity...
 
ROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONSROOT OF NON-LINEAR EQUATIONS
ROOT OF NON-LINEAR EQUATIONS
 
1VectorAdditionofForcesObjectivesTousethe.docx
 1VectorAdditionofForcesObjectivesTousethe.docx 1VectorAdditionofForcesObjectivesTousethe.docx
1VectorAdditionofForcesObjectivesTousethe.docx
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquer
 
Boundness of a neural network weights using the notion of a limit of a sequence
Boundness of a neural network weights using the notion of a limit of a sequenceBoundness of a neural network weights using the notion of a limit of a sequence
Boundness of a neural network weights using the notion of a limit of a sequence
 
JMVA_Paper_Shibasish
JMVA_Paper_ShibasishJMVA_Paper_Shibasish
JMVA_Paper_Shibasish
 
DiffEqPresent.ppt
DiffEqPresent.pptDiffEqPresent.ppt
DiffEqPresent.ppt
 

Último

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 

Último (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 

Tree Algorithm

  • 1. Barnes-Hut Algorithm (TREECODE) The Barnes–Hut simulation (Josh Barnes and Piet Hut) is an algorithm for performing an n-body simulation. It is notable for having order O(n log n) compared to a direct-sum algorithm which would be O(n2). Berkembang dan sudah banyak digunakan dikasus N-body dan SPH karena bisa di paralelisasi. NOTE
  • 2. The crucial idea in speeding up the brute force algorithm is to group nearby bodies and approximate them as a single body. If the group is sufficiently far away, we can approximate its gravitational effects by using its center of mass. If two bodies have positions (x1 , y1) and (x2, y2), and masses m1 and m2, center of mass (x, y) are given by: m = m1 + m2 x = (x1.m1 + x2.m2) / m y = (y1.m1 + y2.m2) / m It recursively divides the set of bodies into groups by storing them in a quad-tree (2D) or Octree (3D), recursively subdivided into quadrants until each subdivision contains 0 or 1 bodies
  • 3. To calculate the net force on a particular body, traverse the nodes of the tree, starting from the root. If the center-of-mass of an internal node is sufficiently far from the body, approximate the bodies contained in that part of the tree as a single body, whose position is the group’s center of mass and whose mass is the group’s total mass. The algorithm is fast because we don’t need to individually examine any of the bodies in the group. If the internal node is not sufficiently far from the body, recursively traverse each of its subtrees. To determine if a node is sufficiently far away, compute the quotient s / d, s = width of the region represented by the internal node, d = the distance between the body and the node’s center-of-mass. Then, compare this ratio against a threshold value θ. If s / d < θ, then the internal node is sufficiently far away. By adjusting the θ parameter, we can change the speed and accuracy of the simulation. We will always use θ = 0.5, a value commonly used in practice. Note that if θ = 0, then no internal node is treated as a single body, and the algorithm degenerates to brute force.
  • 4. CONSTRUCTING THE BARNES-HUT TREE To construct the Barnes-Hut tree, insert the bodies one after another. To insert a body b into the tree rooted at node x, use the following recursive procedure: 1. If node x does not contain a body, put the new body b here. 2. If node x is an internal node, update the center-of-mass and total mass of x. Recursively insert the body b in the appropriate quadrant. 3. If node x is an external node, say containing a body named c, then there are two bodies b and c in the same region. Subdivide the region further by creating four children. Then, recursively insert both b and c into the appropriate quadrant(s). Since b and c may still end up in the same quadrant, there may be several subdivisions during a single insertion. Finally, update the center-of-mass and total mass of x.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Every internal node contain the center of mass and total mass of their bodies.
  • 11. CALCULATING THE FORCE ACTING ON A BODY To calculate the net force acting on body b, use the following recursive procedure, starting with the root of the quad-tree: 1. If the current node is an external node (and it is not body b), calculate the force exerted by the current node on b, and add this amount to b’s net force. 2. Otherwise, calculate the ratio s/d. If s/d < θ, treat this internal node as a single body, and calculate the force it exerts on body b, and add this amount to b’s net force. 3. Otherwise, run the procedure recursively on each of the current node’s children.
  • 12. As an example, to calculate the net force acting on body a, we start at the root node, which is an internal node. It represents the center-of-mass of the six bodies a, b, c, d, e, and f, which have masses 1, 2, 3, 4, 5, and 6 kg, respectively.
  • 13. Jika A terlalu jauh dari pusat massa sistem total (kriteria opening angle terpenuhi) A akan di anggap terkena “gaya” dari sistem itu sendiri (tidak perlu lagi menghitung per node internal).
  • 14.
  • 15. Calculate Quadrapole moment (for b, c and d) if it is included.
  • 16.
  • 17.