Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The attached file (BELOW) ATOMS.DAT is automatically generated by a software commonly used in Physics. The file contains position coordinates for atoms in a specific

The attached file (BELOW) ATOMS.DAT is automatically generated by a software commonly used in Physics. The file contains position coordinates for atoms in a specific solid. The first line of the file is the number of atoms in the file, the second line is the comments, and the rest lines are atoms information which includes type (denoted by an id) of that atom, x, y, and z coordinates.

The distance between atoms may indicates the size, material type, and many other properties of atoms. The task of this assignment is to calculate the average of atomic distance which is within certain range (2.0, 4.0). For example, there are distances for a few pair of atoms in the following table, only those distances within range will be counted.

Atom Pair Distance Average Distance
(a1, a2) 1.5 Too Small
(a7, a30) 2.3 In range, count it in (2.3 + 3.6) / 2 = 2.95
(a34, a5) 6.4 Too large
(a100, a50) 3.6 In range, count it in
(a2, a6) 0.7 Too small
(a3, a6) 5.8 Too small

Name your program as Atoms.c.

In your program, declare two constants MIN_DIS and MAX_DIS for the range [2.0, 4.0]

The formula for calculating distance between two atoms a1(x1, y1, z1) and a2(x2, y2, z2) is

?((??2 ? ??1)^2 + (??2 ? ??1)^2 + (??2 ? ??1)^2)

You may want to calculate distance for all atom pairs. For each distance of a pair, check if it is greater than or equal to MIN_DIS and less than or equal to MAX_DIS. If yes, then count that distance toward average calculation.

To read in a double type number, use: fscanf(filePointer, %lf, &a); Notice we need %lf for double.

Display the average as following (its OK to display more or less digits in fractional part):

The average of distances in range is 3.1678

ATOMS.DAT

216 Cluster output 19 -1.55371 7.86704 7.86704 19 -1.55371 -7.86704 -7.86704 19 1.55371 7.86704 -7.86704 19 1.55371 -7.86704 7.86704 19 1.57724 7.96926 4.76557 19 1.57724 -7.96926 -4.76557 19 1.57724 4.76557 7.96926 19 1.57724 -4.76557 -7.96926 19 -1.57724 -7.96926 4.76557 19 -1.57724 7.96926 -4.76557 19 -1.57724 4.76557 -7.96926 19 -1.57724 -4.76557 7.96926 19 -1.57865 1.57865 7.98381 19 -1.57865 -1.57865 -7.98381 19 -1.57865 7.98381 1.57865 19 -1.57865 -7.98381 -1.57865 19 1.57865 -1.57865 7.98381 19 1.57865 1.57865 -7.98381 19 1.57865 7.98381 -1.57865 19 1.57865 -7.98381 1.57865 19 -1.58694 4.79208 4.79208 19 -1.58694 -4.79208 -4.79208 19 1.58694 4.79208 -4.79208 19 1.58694 -4.79208 4.79208 19 1.59535 4.81436 1.59535 19 1.59535 -4.81436 -1.59535 19 1.59535 1.59535 4.81436 19 1.59535 -1.59535 -4.81436 19 7.98381 1.57865 -1.57865 19 7.98381 -1.57865 1.57865 19 -1.59535 -4.81436 1.59535 19 -1.59535 4.81436 -1.59535 19 -1.59535 1.59535 -4.81436 19 -1.59535 -1.59535 4.81436 19 -1.59785 1.59785 1.59785 19 -1.59785 -1.59785 -1.59785 19 1.59785 -1.59785 1.59785 19 1.59785 1.59785 -1.59785 19 4.72209 7.84588 7.84588 19 4.72209 -7.84588 -7.84588 19 -4.72209 7.84588 -7.84588 19 -4.72209 -7.84588 7.84588 19 -4.73596 4.73596 7.95190 19 -4.73596 -4.73596 -7.95190 19 -4.73596 7.95190 4.73596 19 -4.73596 -7.95190 -4.73596 19 4.73596 -4.73596 7.95190 19 4.73596 4.73596 -7.95190 19 4.73596 7.95190 -4.73596 19 4.73596 -7.95190 4.73596 19 4.76557 7.96926 1.57724 19 4.76557 -7.96926 -1.57724 19 4.76557 1.57724 7.96926 19 4.76557 -1.57724 -7.96926 19 -4.76557 7.96926 -1.57724 19 -4.76557 -7.96926 1.57724 19 -4.76557 -1.57724 7.96926 19 -4.76557 1.57724 -7.96926 19 -7.98381 1.57865 1.57865 19 -7.98381 -1.57865 -1.57865 19 4.77415 4.77415 4.77415 19 4.77415 -4.77415 -4.77415 19 -4.77415 4.77415 -4.77415 19 -4.77415 -4.77415 4.77415 19 4.79208 -1.58694 4.79208 19 4.79208 1.58694 -4.79208 19 4.79208 4.79208 -1.58694 19 4.79208 -4.79208 1.58694 19 -4.79208 -1.58694 -4.79208 19 -4.79208 1.58694 4.79208 19 -4.79208 -4.79208 -1.58694 19 -4.79208 4.79208 1.58694 19 4.81436 1.59535 1.59535 19 4.81436 -1.59535 -1.59535 19 -4.81436 1.59535 -1.59535 19 -4.81436 -1.59535 1.59535 19 -7.71174 -7.71174 -7.71174 19 -7.71174 7.71174 7.71174 19 7.71174 -7.71174 7.71174 19 7.71174 7.71174 -7.71174 19 -7.84588 -4.72209 7.84588 19 -7.84588 4.72209 -7.84588 19 -7.84588 7.84588 -4.72209 19 -7.84588 -7.84588 4.72209 19 7.84588 4.72209 7.84588 19 7.84588 -4.72209 -7.84588 19 7.84588 7.84588 4.72209 19 7.84588 -7.84588 -4.72209 19 -7.86704 1.55371 7.86704 19 -7.86704 -1.55371 -7.86704 19 -7.86704 7.86704 1.55371 19 -7.86704 -7.86704 -1.55371 19 7.86704 -1.55371 7.86704 19 7.86704 1.55371 -7.86704 19 7.86704 7.86704 -1.55371 19 7.86704 -7.86704 1.55371 19 -7.95190 4.73596 4.73596 19 -7.95190 -4.73596 -4.73596 19 7.95190 4.73596 -4.73596 19 7.95190 -4.73596 4.73596 19 -7.96926 1.57724 -4.76557 19 -7.96926 -1.57724 4.76557 19 -7.96926 -4.76557 1.57724 19 -7.96926 4.76557 -1.57724 19 7.96926 4.76557 1.57724 19 7.96926 -4.76557 -1.57724 19 7.96926 1.57724 4.76557 19 7.96926 -1.57724 -4.76557 17 1.56353 7.92007 7.92007 17 1.56353 -7.92007 -7.92007 17 -1.56353 -7.92007 7.92007 17 -1.56353 7.92007 -7.92007 17 1.58184 4.78284 4.78284 17 1.58184 -4.78284 -4.78284 17 -1.58184 4.78284 -4.78284 17 -1.58184 -4.78284 4.78284 17 1.58240 8.03432 1.58240 17 1.58240 -8.03432 -1.58240 17 1.58240 1.58240 8.03432 17 1.58240 -1.58240 -8.03432 17 -1.58240 -8.03432 1.58240 17 -1.58240 8.03432 -1.58240 17 -1.58240 1.58240 -8.03432 17 -1.58240 -1.58240 8.03432 17 -1.58809 8.02031 4.74836 17 -1.58809 -8.02031 -4.74836 17 -1.58809 4.74836 8.02031 17 -1.58809 -4.74836 -8.02031 17 1.58809 8.02031 -4.74836 17 1.58809 -8.02031 4.74836 17 1.58809 -4.74836 8.02031 17 1.58809 4.74836 -8.02031 17 -1.59616 4.80395 1.59616 17 -1.59616 -4.80395 -1.59616 17 -1.59616 1.59616 4.80395 17 -1.59616 -1.59616 -4.80395 17 1.59616 4.80395 -1.59616 17 1.59616 -4.80395 1.59616 17 1.59616 -1.59616 4.80395 17 1.59616 1.59616 -4.80395 17 1.60192 -1.60192 -1.60192 17 1.60192 1.60192 1.60192 17 -1.60192 1.60192 -1.60192 17 -1.60192 -1.60192 1.60192 17 -4.69967 7.91291 7.91291 17 -4.69967 -7.91291 -7.91291 17 4.69967 7.91291 -7.91291 17 4.69967 -7.91291 7.91291 17 4.71369 7.98753 4.71369 17 4.71369 -7.98753 -4.71369 17 4.71369 4.71369 7.98753 17 4.71369 -4.71369 -7.98753 17 -4.71369 7.98753 -4.71369 17 -4.71369 -7.98753 4.71369 17 -4.71369 -4.71369 7.98753 17 -4.71369 4.71369 -7.98753 17 4.74836 8.02031 -1.58809 17 4.74836 -8.02031 1.58809 17 4.74836 -1.58809 8.02031 17 4.74836 1.58809 -8.02031 17 -4.74836 -8.02031 -1.58809 17 -4.74836 8.02031 1.58809 17 -4.74836 -1.58809 -8.02031 17 -4.74836 1.58809 8.02031 17 -4.77397 -4.77397 -4.77397 17 -4.77397 4.77397 4.77397 17 4.77397 -4.77397 4.77397 17 4.77397 4.77397 -4.77397 17 4.78284 1.58184 4.78284 17 4.78284 -1.58184 -4.78284 17 4.78284 4.78284 1.58184 17 4.78284 -4.78284 -1.58184 17 -4.78284 1.58184 -4.78284 17 -4.78284 -1.58184 4.78284 17 -4.78284 -4.78284 1.58184 17 -4.78284 4.78284 -1.58184 17 4.80395 -1.59616 1.59616 17 4.80395 1.59616 -1.59616 17 -4.80395 -1.59616 -1.59616 17 -4.80395 1.59616 1.59616 17 -7.76874 -7.76874 7.76874 17 -7.76874 7.76874 -7.76874 17 7.76874 7.76874 7.76874 17 7.76874 -7.76874 -7.76874 17 -7.91291 4.69967 7.91291 17 -7.91291 -4.69967 -7.91291 17 -7.91291 7.91291 4.69967 17 -7.91291 -7.91291 -4.69967 17 7.91291 -4.69967 7.91291 17 7.91291 4.69967 -7.91291 17 7.91291 7.91291 -4.69967 17 7.91291 -7.91291 4.69967 17 -7.92007 1.56353 -7.92007 17 -7.92007 -1.56353 7.92007 17 -7.92007 -7.92007 1.56353 17 -7.92007 7.92007 -1.56353 17 7.92007 7.92007 1.56353 17 7.92007 -7.92007 -1.56353 17 7.92007 1.56353 7.92007 17 7.92007 -1.56353 -7.92007 17 -7.98753 -4.71369 4.71369 17 -7.98753 4.71369 -4.71369 17 7.98753 4.71369 4.71369 17 7.98753 -4.71369 -4.71369 17 -8.02031 4.74836 1.58809 17 -8.02031 -4.74836 -1.58809 17 -8.02031 1.58809 4.74836 17 -8.02031 -1.58809 -4.74836 17 8.02031 -1.58809 4.74836 17 8.02031 1.58809 -4.74836 17 8.02031 4.74836 -1.58809 17 8.02031 -4.74836 1.58809 17 8.03432 -1.58240 -1.58240 17 8.03432 1.58240 1.58240 17 -8.03432 1.58240 -1.58240 17 -8.03432 -1.58240 1.58240

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions