From 25ef37f62b865ce9069e96443034c92cbd9307f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Gonz=C3=A1lez?= Date: Tue, 17 Feb 2026 17:35:51 +0100 Subject: [PATCH] new units were not loaded --- assets/formulas/formulas.d4rt | 661 ++++++++++++++++++++++++++++ assets/units/amount.d4rt.units | 10 + assets/units/charge.d4rt.units | 14 + assets/units/derived.d4rt.units | 29 ++ assets/units/power.d4rt.units | 23 + assets/units/temperature.d4rt.units | 1 + assets/units/volume.d4rt.units | 22 + flutterw | 11 +- lib/database/database_service.dart | 4 +- lib/defaults/default_corpus.dart | 5 + 10 files changed, 776 insertions(+), 4 deletions(-) create mode 100644 assets/units/amount.d4rt.units create mode 100644 assets/units/charge.d4rt.units create mode 100644 assets/units/derived.d4rt.units create mode 100644 assets/units/power.d4rt.units create mode 100644 assets/units/volume.d4rt.units diff --git a/assets/formulas/formulas.d4rt b/assets/formulas/formulas.d4rt index af27f3c..e3ced5d 100644 --- a/assets/formulas/formulas.d4rt +++ b/assets/formulas/formulas.d4rt @@ -387,5 +387,666 @@ This identity is derived from the Pythagorean theorem applied to the unit circle result = pow(sin(thetaRad), 2) + pow(cos(thetaRad), 2); """, "tags": ["trigonometry", "identity", "sine", "cosine"] + }, + + // Gravitational Potential Energy + { + "name": "Gravitational Potential Energy", + "description": r''' +Energy possessed by an object due to its position in a gravitational field + +$$PE = mgh$$ + +Where: +- $m$: Mass of object (kilograms) +- $g$: Gravitational acceleration ($9.81\ \mathrm{m/s^2}$ on Earth) +- $h$: Height above reference point (meters) + +This energy increases with height and can be converted to kinetic energy.''', + "input": [ + {"name": "m", "unit": "kilogram"}, // Mass + {"name": "h", "unit": "meter"}, // Height + {"name": "g", "unit": "meters per square second"} // Gravitational acceleration + ], + "output": {"name": "PE", "unit": "joule"}, // Potential energy + "d4rtCode": "PE = m * g * h;", + "tags": ["physics", "energy", "mechanics", "gravity"] + }, + + // Linear Momentum + { + "name": "Linear Momentum", + "description": r''' +Quantity of motion possessed by a moving object + +$$p = mv$$ + +Where: +- $p$: Momentum ($\mathrm{kg \cdot m/s}$) +- $m$: Mass (kilograms) +- $v$: Velocity (m/s) + +Momentum is conserved in isolated systems.''', + "input": [ + {"name": "m", "unit": "kilogram"}, // Mass + {"name": "v", "unit": "meters per second"} // Velocity + ], + "output": {"name": "p", "unit": "kilogram meter per second"}, // Momentum + "d4rtCode": "p = m * v;", + "tags": ["physics", "mechanics", "momentum"] + }, + + // Density + { + "name": "Density", + "description": r''' +Mass per unit volume of a substance + +$$\rho = \frac{m}{V}$$ + +Where: +- $\rho$: Density ($\mathrm{kg/m^3}$) +- $m$: Mass (kilograms) +- $V$: Volume (cubic meters) + +Density is an intrinsic property of materials.''', + "input": [ + {"name": "m", "unit": "kilogram"}, // Mass + {"name": "V", "unit": "cubic meter"} // Volume + ], + "output": {"name": "rho", "unit": "kilogram per cubic meter"}, // Density + "d4rtCode": "rho = m / V;", + "tags": ["physics", "mechanics", "material"] + }, + + // Pressure + { + "name": "Pressure", + "description": r''' +Force applied perpendicular to a surface per unit area + +$$P = \frac{F}{A}$$ + +Where: +- $P$: Pressure (Pascals) +- $F$: Force (Newtons) +- $A$: Area (square meters) + +Pressure is transmitted equally in all directions in fluids.''', + "input": [ + {"name": "F", "unit": "newton"}, // Force + {"name": "A", "unit": "square meter"} // Area + ], + "output": {"name": "P", "unit": "pascal"}, // Pressure + "d4rtCode": "P = F / A;", + "tags": ["physics", "mechanics", "fluid"] + }, + + // Work + { + "name": "Work", + "description": r''' +Energy transferred when a force moves an object + +$$W = Fd\cos(\theta)$$ + +Where: +- $W$: Work (Joules) +- $F$: Force (Newtons) +- $d$: Displacement (meters) +- $\theta$: Angle between force and displacement + +Maximum work occurs when force and displacement are parallel.''', + "input": [ + {"name": "F", "unit": "newton"}, // Force + {"name": "d", "unit": "meter"}, // Displacement + {"name": "theta", "unit": "degree"} // Angle + ], + "output": {"name": "W", "unit": "joule"}, // Work + "d4rtCode": """ + var thetaRad = theta * (pi / 180); + W = F * d * cos(thetaRad); + """, + "tags": ["physics", "energy", "mechanics"] + }, + + // Power + { + "name": "Power", + "description": r''' +Rate at which work is done or energy is transferred + +$$P = \frac{W}{t}$$ + +Where: +- $P$: Power (Watts) +- $W$: Work or Energy (Joules) +- $t$: Time (seconds) + +Power measures how quickly energy is used or transferred.''', + "input": [ + {"name": "W", "unit": "joule"}, // Work or Energy + {"name": "t", "unit": "second"} // Time + ], + "output": {"name": "P", "unit": "watt"}, // Power + "d4rtCode": "P = W / t;", + "tags": ["physics", "energy", "mechanics"] + }, + + // Coulomb's Law + { + "name": "Coulomb's Law", + "description": r''' +Force between two electrically charged particles + +$$F = k_e\frac{q_1q_2}{r^2}$$ + +Where: +- $F$: Electrostatic force (Newtons) +- $k_e$: Coulomb's constant $8.988\times 10^9\ \mathrm{N\cdot m^2/C^2}$ +- $q_1, q_2$: Electric charges (Coulombs) +- $r$: Distance between charges (meters) + +Like charges repel, opposite charges attract.''', + "input": [ + {"name": "q1", "unit": "coulomb"}, // Charge 1 + {"name": "q2", "unit": "coulomb"}, // Charge 2 + {"name": "r", "unit": "meter"} // Distance + ], + "output": {"name": "F", "unit": "newton"}, // Force + "d4rtCode": "F = (8.9875517923e9 * q1 * q2) / pow(r, 2);", + "tags": ["physics", "electricity", "electrostatics"] + }, + + // Electric Power + { + "name": "Electric Power", + "description": r''' +Rate at which electrical energy is transferred + +$$P = VI$$ + +Where: +- $P$: Power (Watts) +- $V$: Voltage (Volts) +- $I$: Current (Amperes) + +This formula is fundamental in electrical circuit analysis.''', + "input": [ + {"name": "V", "unit": "volt"}, // Voltage + {"name": "I", "unit": "ampere"} // Current + ], + "output": {"name": "P", "unit": "watt"}, // Power + "d4rtCode": "P = V * I;", + "tags": ["physics", "electricity", "electronics"] + }, + + // Ideal Gas Law + { + "name": "Ideal Gas Law", + "description": r''' +Equation of state for an ideal gas + +$$PV = nRT$$ + +Where: +- $P$: Pressure (Pascals) +- $V$: Volume (cubic meters) +- $n$: Amount of substance (moles) +- $R$: Universal gas constant $8.314\ \mathrm{J/(mol\cdot K)}$ +- $T$: Temperature (Kelvin) + +This law combines Boyle's, Charles's, and Avogadro's laws.''', + "input": [ + {"name": "n", "unit": "mole"}, // Amount of substance + {"name": "T", "unit": "kelvin"}, // Temperature + {"name": "V", "unit": "cubic meter"} // Volume + ], + "output": {"name": "P", "unit": "pascal"}, // Pressure + "d4rtCode": "P = (n * 8.314462618 * T) / V;", + "tags": ["physics", "thermodynamics", "gas"] + }, + + // Snell's Law + { + "name": "Snell's Law", + "description": r''' +Law describing refraction of light at interface between media + +$$n_1\sin(\theta_1) = n_2\sin(\theta_2)$$ + +Where: +- $n_1, n_2$: Refractive indices of the two media +- $\theta_1$: Angle of incidence +- $\theta_2$: Angle of refraction + +This law explains how light bends when passing between materials.''', + "input": [ + {"name": "n1", "unit": "scalar"}, // Refractive index 1 + {"name": "n2", "unit": "scalar"}, // Refractive index 2 + {"name": "theta1", "unit": "degree"} // Angle of incidence + ], + "output": {"name": "theta2", "unit": "degree"}, // Angle of refraction + "d4rtCode": """ + var theta1Rad = theta1 * (pi / 180); + var sinTheta2 = (n1 * sin(theta1Rad)) / n2; + theta2 = asin(sinTheta2) * (180 / pi); + """, + "tags": ["physics", "optics", "light"] + }, + + // Buoyant Force (Archimedes' Principle) + { + "name": "Buoyant Force", + "description": r''' +Upward force exerted on an object immersed in a fluid + +$$F_b = \rho g V$$ + +Where: +- $F_b$: Buoyant force (Newtons) +- $\rho$: Fluid density ($\mathrm{kg/m^3}$) +- $g$: Gravitational acceleration ($\mathrm{m/s^2}$) +- $V$: Displaced volume (cubic meters) + +An object floats when buoyant force equals its weight.''', + "input": [ + {"name": "rho", "unit": "kilogram per cubic meter"}, // Fluid density + {"name": "g", "unit": "meters per square second"}, // Gravitational acceleration + {"name": "V", "unit": "cubic meter"} // Displaced volume + ], + "output": {"name": "Fb", "unit": "newton"}, // Buoyant force + "d4rtCode": "Fb = rho * g * V;", + "tags": ["physics", "fluid", "mechanics"] + }, + + // Area of Circle + { + "name": "Area of Circle", + "description": r''' +Area enclosed by a circle + +$$A = \pi r^2$$ + +Where: +- $A$: Area (square meters) +- $r$: Radius (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The area is proportional to the square of the radius.''', + "input": [ + {"name": "r", "unit": "meter"} // Radius + ], + "output": {"name": "A", "unit": "square meter"}, // Area + "d4rtCode": "A = pi * pow(r, 2);", + "tags": ["geometry", "circle", "area"] + }, + + // Circumference of Circle + { + "name": "Circumference of Circle", + "description": r''' +Perimeter (distance around) a circle + +$$C = 2\pi r$$ + +Where: +- $C$: Circumference (meters) +- $r$: Radius (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The circumference is proportional to the radius.''', + "input": [ + {"name": "r", "unit": "meter"} // Radius + ], + "output": {"name": "C", "unit": "meter"}, // Circumference + "d4rtCode": "C = 2 * pi * r;", + "tags": ["geometry", "circle", "perimeter"] + }, + + // Area of Triangle + { + "name": "Area of Triangle", + "description": r''' +Area enclosed by a triangle + +$$A = \frac{1}{2}bh$$ + +Where: +- $A$: Area (square meters) +- $b$: Base length (meters) +- $h$: Height perpendicular to base (meters) + +This formula works for any triangle.''', + "input": [ + {"name": "b", "unit": "meter"}, // Base + {"name": "h", "unit": "meter"} // Height + ], + "output": {"name": "A", "unit": "square meter"}, // Area + "d4rtCode": "A = 0.5 * b * h;", + "tags": ["geometry", "triangle", "area"] + }, + + // Area of Rectangle + { + "name": "Area of Rectangle", + "description": r''' +Area enclosed by a rectangle + +$$A = lw$$ + +Where: +- $A$: Area (square meters) +- $l$: Length (meters) +- $w$: Width (meters) + +The area is the product of length and width.''', + "input": [ + {"name": "l", "unit": "meter"}, // Length + {"name": "w", "unit": "meter"} // Width + ], + "output": {"name": "A", "unit": "square meter"}, // Area + "d4rtCode": "A = l * w;", + "tags": ["geometry", "rectangle", "area"] + }, + + // Area of Trapezoid + { + "name": "Area of Trapezoid", + "description": r''' +Area enclosed by a trapezoid + +$$A = \frac{1}{2}(a+b)h$$ + +Where: +- $A$: Area (square meters) +- $a, b$: Lengths of parallel sides (meters) +- $h$: Height (perpendicular distance between parallel sides, meters) + +The area is the average of parallel sides times height.''', + "input": [ + {"name": "a", "unit": "meter"}, // Parallel side 1 + {"name": "b", "unit": "meter"}, // Parallel side 2 + {"name": "h", "unit": "meter"} // Height + ], + "output": {"name": "A", "unit": "square meter"}, // Area + "d4rtCode": "A = 0.5 * (a + b) * h;", + "tags": ["geometry", "trapezoid", "area"] + }, + + // Volume of Sphere + { + "name": "Volume of Sphere", + "description": r''' +Volume enclosed by a sphere + +$$V = \frac{4}{3}\pi r^3$$ + +Where: +- $V$: Volume (cubic meters) +- $r$: Radius (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The volume is proportional to the cube of the radius.''', + "input": [ + {"name": "r", "unit": "meter"} // Radius + ], + "output": {"name": "V", "unit": "cubic meter"}, // Volume + "d4rtCode": "V = (4.0/3.0) * pi * pow(r, 3);", + "tags": ["geometry", "sphere", "volume"] + }, + + // Surface Area of Sphere + { + "name": "Surface Area of Sphere", + "description": r''' +Total surface area of a sphere + +$$A = 4\pi r^2$$ + +Where: +- $A$: Surface area (square meters) +- $r$: Radius (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The surface area is four times the area of a circle with the same radius.''', + "input": [ + {"name": "r", "unit": "meter"} // Radius + ], + "output": {"name": "A", "unit": "square meter"}, // Surface area + "d4rtCode": "A = 4 * pi * pow(r, 2);", + "tags": ["geometry", "sphere", "surface area"] + }, + + // Volume of Cylinder + { + "name": "Volume of Cylinder", + "description": r''' +Volume enclosed by a cylinder + +$$V = \pi r^2 h$$ + +Where: +- $V$: Volume (cubic meters) +- $r$: Radius of base (meters) +- $h$: Height (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The volume is the area of the base times the height.''', + "input": [ + {"name": "r", "unit": "meter"}, // Radius + {"name": "h", "unit": "meter"} // Height + ], + "output": {"name": "V", "unit": "cubic meter"}, // Volume + "d4rtCode": "V = pi * pow(r, 2) * h;", + "tags": ["geometry", "cylinder", "volume"] + }, + + // Surface Area of Cylinder + { + "name": "Surface Area of Cylinder", + "description": r''' +Total surface area of a cylinder (including top and bottom) + +$$A = 2\pi r(r + h)$$ + +Where: +- $A$: Total surface area (square meters) +- $r$: Radius of base (meters) +- $h$: Height (meters) +- $\pi$: Pi ($\approx 3.14159$) + +This includes the lateral surface plus the two circular ends.''', + "input": [ + {"name": "r", "unit": "meter"}, // Radius + {"name": "h", "unit": "meter"} // Height + ], + "output": {"name": "A", "unit": "square meter"}, // Surface area + "d4rtCode": "A = 2 * pi * r * (r + h);", + "tags": ["geometry", "cylinder", "surface area"] + }, + + // Volume of Cone + { + "name": "Volume of Cone", + "description": r''' +Volume enclosed by a cone + +$$V = \frac{1}{3}\pi r^2 h$$ + +Where: +- $V$: Volume (cubic meters) +- $r$: Radius of base (meters) +- $h$: Height (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The volume is one-third the volume of a cylinder with the same base and height.''', + "input": [ + {"name": "r", "unit": "meter"}, // Radius + {"name": "h", "unit": "meter"} // Height + ], + "output": {"name": "V", "unit": "cubic meter"}, // Volume + "d4rtCode": "V = (1.0/3.0) * pi * pow(r, 2) * h;", + "tags": ["geometry", "cone", "volume"] + }, + + // Volume of Cube + { + "name": "Volume of Cube", + "description": r''' +Volume enclosed by a cube + +$$V = s^3$$ + +Where: +- $V$: Volume (cubic meters) +- $s$: Side length (meters) + +The volume is the cube of the side length.''', + "input": [ + {"name": "s", "unit": "meter"} // Side length + ], + "output": {"name": "V", "unit": "cubic meter"}, // Volume + "d4rtCode": "V = pow(s, 3);", + "tags": ["geometry", "cube", "volume"] + }, + + // Surface Area of Cube + { + "name": "Surface Area of Cube", + "description": r''' +Total surface area of a cube + +$$A = 6s^2$$ + +Where: +- $A$: Total surface area (square meters) +- $s$: Side length (meters) + +The surface area is six times the area of one face.''', + "input": [ + {"name": "s", "unit": "meter"} // Side length + ], + "output": {"name": "A", "unit": "square meter"}, // Surface area + "d4rtCode": "A = 6 * pow(s, 2);", + "tags": ["geometry", "cube", "surface area"] + }, + + // Perimeter of Rectangle + { + "name": "Perimeter of Rectangle", + "description": r''' +Total distance around a rectangle + +$$P = 2(l + w)$$ + +Where: +- $P$: Perimeter (meters) +- $l$: Length (meters) +- $w$: Width (meters) + +The perimeter is twice the sum of length and width.''', + "input": [ + {"name": "l", "unit": "meter"}, // Length + {"name": "w", "unit": "meter"} // Width + ], + "output": {"name": "P", "unit": "meter"}, // Perimeter + "d4rtCode": "P = 2 * (l + w);", + "tags": ["geometry", "rectangle", "perimeter"] + }, + + // Perimeter of Triangle + { + "name": "Perimeter of Triangle", + "description": r''' +Total distance around a triangle + +$$P = a + b + c$$ + +Where: +- $P$: Perimeter (meters) +- $a, b, c$: Side lengths (meters) + +The perimeter is the sum of all three sides.''', + "input": [ + {"name": "a", "unit": "meter"}, // Side 1 + {"name": "b", "unit": "meter"}, // Side 2 + {"name": "c", "unit": "meter"} // Side 3 + ], + "output": {"name": "P", "unit": "meter"}, // Perimeter + "d4rtCode": "P = a + b + c;", + "tags": ["geometry", "triangle", "perimeter"] + }, + + // Area of Regular Polygon + { + "name": "Area of Regular Polygon", + "description": r''' +Area of a regular polygon with n sides + +$$A = \frac{1}{4}ns^2\cot(\frac{\pi}{n})$$ + +Where: +- $A$: Area (square meters) +- $n$: Number of sides +- $s$: Side length (meters) +- $\pi$: Pi ($\approx 3.14159$) + +This formula works for any regular polygon (equal sides and angles).''', + "input": [ + {"name": "n", "unit": "scalar"}, // Number of sides + {"name": "s", "unit": "meter"} // Side length + ], + "output": {"name": "A", "unit": "square meter"}, // Area + "d4rtCode": "A = 0.25 * n * pow(s, 2) * (cos(pi/n) / sin(pi/n));", + "tags": ["geometry", "polygon", "area"] + }, + + // Sum of Interior Angles of Polygon + { + "name": "Sum of Interior Angles", + "description": r''' +Sum of interior angles of a polygon + +$$S = (n - 2) \times 180°$$ + +Where: +- $S$: Sum of interior angles (degrees) +- $n$: Number of sides + +This formula works for any simple polygon.''', + "input": [ + {"name": "n", "unit": "scalar"} // Number of sides + ], + "output": {"name": "S", "unit": "degree"}, // Sum of angles + "d4rtCode": "S = (n - 2) * 180;", + "tags": ["geometry", "polygon", "angles"] + }, + + // Heron's Formula (Area of Triangle) + { + "name": "Heron's Formula", + "description": r''' +Area of a triangle using only side lengths + +$$A = \sqrt{s(s-a)(s-b)(s-c)}$$ + +Where: +- $A$: Area (square meters) +- $a, b, c$: Side lengths (meters) +- $s$: Semi-perimeter $= \frac{a+b+c}{2}$ + +This formula is useful when height is unknown.''', + "input": [ + {"name": "a", "unit": "meter"}, // Side 1 + {"name": "b", "unit": "meter"}, // Side 2 + {"name": "c", "unit": "meter"} // Side 3 + ], + "output": {"name": "A", "unit": "square meter"}, // Area + "d4rtCode": """ + var s = (a + b + c) / 2; + A = sqrt(s * (s - a) * (s - b) * (s - c)); + """, + "tags": ["geometry", "triangle", "area"] } ] diff --git a/assets/units/amount.d4rt.units b/assets/units/amount.d4rt.units new file mode 100644 index 0000000..719c748 --- /dev/null +++ b/assets/units/amount.d4rt.units @@ -0,0 +1,10 @@ +[ + {"name": "mole", "symbol": "mol", "isBase": true}, + {"name": "millimole", "symbol": "mmol", "baseUnit": "mole", "factor": 0.001}, + {"name": "micromole", "symbol": "µmol", "baseUnit": "mole", "factor": 0.000001}, + {"name": "nanomole", "symbol": "nmol", "baseUnit": "mole", "factor": 0.000000001}, + {"name": "picomole", "symbol": "pmol", "baseUnit": "mole", "factor": 0.000000000001}, + {"name": "kilomole", "symbol": "kmol", "baseUnit": "mole", "factor": 1000}, + {"name": "pound-mole", "symbol": "lb-mol", "baseUnit": "mole", "factor": 453.59237}, + {"name": "kilopound-mole", "symbol": "kip-mol", "baseUnit": "mole", "factor": 453592.37} +] diff --git a/assets/units/charge.d4rt.units b/assets/units/charge.d4rt.units new file mode 100644 index 0000000..7dc6f8c --- /dev/null +++ b/assets/units/charge.d4rt.units @@ -0,0 +1,14 @@ +[ + {"name": "coulomb", "symbol": "C", "isBase": true}, + {"name": "millicoulomb", "symbol": "mC", "baseUnit": "coulomb", "factor": 0.001}, + {"name": "microcoulomb", "symbol": "µC", "baseUnit": "coulomb", "factor": 0.000001}, + {"name": "nanocoulomb", "symbol": "nC", "baseUnit": "coulomb", "factor": 0.000000001}, + {"name": "picocoulomb", "symbol": "pC", "baseUnit": "coulomb", "factor": 0.000000000001}, + {"name": "elementary charge", "symbol": "e", "baseUnit": "coulomb", "factor": 1.602176634e-19}, + {"name": "faraday", "symbol": "F", "baseUnit": "coulomb", "factor": 96485.33212}, + {"name": "ampere hour", "symbol": "A·h", "baseUnit": "coulomb", "factor": 3600}, + {"name": "milliampere hour", "symbol": "mA·h", "baseUnit": "coulomb", "factor": 3.6}, + {"name": "abcoulomb", "symbol": "abC", "baseUnit": "coulomb", "factor": 10}, + {"name": "statcoulomb", "symbol": "statC", "baseUnit": "coulomb", "factor": 3.33564095198152e-10}, + {"name": "franklin", "symbol": "Fr", "baseUnit": "coulomb", "factor": 3.33564095198152e-10} +] diff --git a/assets/units/derived.d4rt.units b/assets/units/derived.d4rt.units new file mode 100644 index 0000000..a03c814 --- /dev/null +++ b/assets/units/derived.d4rt.units @@ -0,0 +1,29 @@ +[ + {"name": "kilogram per cubic meter", "symbol": "kg/m³", "isBase": true}, + {"name": "gram per cubic meter", "symbol": "g/m³", "baseUnit": "kilogram per cubic meter", "factor": 0.001}, + {"name": "gram per cubic centimeter", "symbol": "g/cm³", "baseUnit": "kilogram per cubic meter", "factor": 1000}, + {"name": "gram per milliliter", "symbol": "g/mL", "baseUnit": "kilogram per cubic meter", "factor": 1000}, + {"name": "gram per liter", "symbol": "g/L", "baseUnit": "kilogram per cubic meter", "factor": 1}, + {"name": "kilogram per liter", "symbol": "kg/L", "baseUnit": "kilogram per cubic meter", "factor": 1000}, + {"name": "pound per cubic foot", "symbol": "lb/ft³", "baseUnit": "kilogram per cubic meter", "factor": 16.018463373960142}, + {"name": "pound per cubic inch", "symbol": "lb/in³", "baseUnit": "kilogram per cubic meter", "factor": 27679.904710203122}, + {"name": "pound per gallon (US)", "symbol": "lb/gal (US)", "baseUnit": "kilogram per cubic meter", "factor": 119.82642731692088}, + {"name": "pound per gallon (UK)", "symbol": "lb/gal (UK)", "baseUnit": "kilogram per cubic meter", "factor": 99.7763726624036}, + {"name": "ounce per cubic foot", "symbol": "oz/ft³", "baseUnit": "kilogram per cubic meter", "factor": 1.0011539608725089}, + {"name": "ounce per cubic inch", "symbol": "oz/in³", "baseUnit": "kilogram per cubic meter", "factor": 1729.9940443876951}, + {"name": "ounce per gallon (US)", "symbol": "oz/gal (US)", "baseUnit": "kilogram per cubic meter", "factor": 7.489151707307555}, + {"name": "ounce per gallon (UK)", "symbol": "oz/gal (UK)", "baseUnit": "kilogram per cubic meter", "factor": 6.236023291400225}, + {"name": "slug per cubic foot", "symbol": "slug/ft³", "baseUnit": "kilogram per cubic meter", "factor": 515.3788183932036}, + {"name": "ton (short) per cubic yard", "symbol": "ton (US)/yd³", "baseUnit": "kilogram per cubic meter", "factor": 1186.552842515002}, + {"name": "ton (long) per cubic yard", "symbol": "ton (UK)/yd³", "baseUnit": "kilogram per cubic meter", "factor": 1328.9391836171522}, + {"name": "specific gravity", "symbol": "SG", "baseUnit": "kilogram per cubic meter", "factor": 1000}, + + {"name": "kilogram meter per second", "symbol": "kg·m/s", "isBase": true}, + {"name": "gram meter per second", "symbol": "g·m/s", "baseUnit": "kilogram meter per second", "factor": 0.001}, + {"name": "kilogram kilometer per hour", "symbol": "kg·km/h", "baseUnit": "kilogram meter per second", "factor": 0.2777777777777778}, + {"name": "pound foot per second", "symbol": "lb·ft/s", "baseUnit": "kilogram meter per second", "factor": 0.138254954376}, + {"name": "pound foot per minute", "symbol": "lb·ft/min", "baseUnit": "kilogram meter per second", "factor": 0.0023042492396}, + {"name": "slug foot per second", "symbol": "slug·ft/s", "baseUnit": "kilogram meter per second", "factor": 4.4482216152605}, + {"name": "newton second", "symbol": "N·s", "baseUnit": "kilogram meter per second", "factor": 1}, + {"name": "dyne second", "symbol": "dyn·s", "baseUnit": "kilogram meter per second", "factor": 0.00001} +] diff --git a/assets/units/power.d4rt.units b/assets/units/power.d4rt.units new file mode 100644 index 0000000..f83976b --- /dev/null +++ b/assets/units/power.d4rt.units @@ -0,0 +1,23 @@ +[ + {"name": "watt", "symbol": "W", "isBase": true}, + {"name": "milliwatt", "symbol": "mW", "baseUnit": "watt", "factor": 0.001}, + {"name": "microwatt", "symbol": "µW", "baseUnit": "watt", "factor": 0.000001}, + {"name": "nanowatt", "symbol": "nW", "baseUnit": "watt", "factor": 0.000000001}, + {"name": "picowatt", "symbol": "pW", "baseUnit": "watt", "factor": 0.000000000001}, + {"name": "kilowatt", "symbol": "kW", "baseUnit": "watt", "factor": 1000}, + {"name": "megawatt", "symbol": "MW", "baseUnit": "watt", "factor": 1000000}, + {"name": "gigawatt", "symbol": "GW", "baseUnit": "watt", "factor": 1000000000}, + {"name": "terawatt", "symbol": "TW", "baseUnit": "watt", "factor": 1000000000000}, + {"name": "horsepower (metric)", "symbol": "hp (metric)", "baseUnit": "watt", "factor": 735.49875}, + {"name": "horsepower (mechanical)", "symbol": "hp (mech)", "baseUnit": "watt", "factor": 745.6998715822702}, + {"name": "horsepower (electrical)", "symbol": "hp (elec)", "baseUnit": "watt", "factor": 746}, + {"name": "horsepower (boiler)", "symbol": "hp (boiler)", "baseUnit": "watt", "factor": 9809.5}, + {"name": "BTU per hour", "symbol": "BTU/h", "baseUnit": "watt", "factor": 0.29307107}, + {"name": "BTU per minute", "symbol": "BTU/min", "baseUnit": "watt", "factor": 17.5842642}, + {"name": "BTU per second", "symbol": "BTU/s", "baseUnit": "watt", "factor": 1055.05585262}, + {"name": "calorie per second", "symbol": "cal/s", "baseUnit": "watt", "factor": 4.184}, + {"name": "kilocalorie per hour", "symbol": "kcal/h", "baseUnit": "watt", "factor": 1.163}, + {"name": "erg per second", "symbol": "erg/s", "baseUnit": "watt", "factor": 0.0000001}, + {"name": "foot-pound per second", "symbol": "ft·lb/s", "baseUnit": "watt", "factor": 1.3558179483314004}, + {"name": "foot-pound per minute", "symbol": "ft·lb/min", "baseUnit": "watt", "factor": 0.02259696580552334} +] diff --git a/assets/units/temperature.d4rt.units b/assets/units/temperature.d4rt.units index 5c27bae..61c23c6 100644 --- a/assets/units/temperature.d4rt.units +++ b/assets/units/temperature.d4rt.units @@ -1,5 +1,6 @@ [ {"name": "Kelvin", "symbol": "K", "isBase": true}, + {"name": "kelvin", "symbol": "K", "baseUnit": "Kelvin", "factor": 1}, { "name": "Celsius", "symbol": "°C", diff --git a/assets/units/volume.d4rt.units b/assets/units/volume.d4rt.units new file mode 100644 index 0000000..d5ee0f1 --- /dev/null +++ b/assets/units/volume.d4rt.units @@ -0,0 +1,22 @@ +[ + {"name": "cubic meter", "symbol": "m³", "isBase": true}, + {"name": "cubic kilometer", "symbol": "km³", "baseUnit": "cubic meter", "factor": 1000000000}, + {"name": "cubic centimeter", "symbol": "cm³", "baseUnit": "cubic meter", "factor": 0.000001}, + {"name": "cubic millimeter", "symbol": "mm³", "baseUnit": "cubic meter", "factor": 0.000000001}, + {"name": "cubic inch", "symbol": "in³", "baseUnit": "cubic meter", "factor": 0.000016387064}, + {"name": "cubic foot", "symbol": "ft³", "baseUnit": "cubic meter", "factor": 0.028316846592}, + {"name": "cubic yard", "symbol": "yd³", "baseUnit": "cubic meter", "factor": 0.764554857984}, + {"name": "liter", "symbol": "L", "baseUnit": "cubic meter", "factor": 0.001}, + {"name": "milliliter", "symbol": "mL", "baseUnit": "cubic meter", "factor": 0.000001}, + {"name": "gallon (US)", "symbol": "gal (US)", "baseUnit": "cubic meter", "factor": 0.003785411784}, + {"name": "gallon (UK)", "symbol": "gal (UK)", "baseUnit": "cubic meter", "factor": 0.00454609}, + {"name": "quart (US)", "symbol": "qt (US)", "baseUnit": "cubic meter", "factor": 0.000946352946}, + {"name": "pint (US)", "symbol": "pt (US)", "baseUnit": "cubic meter", "factor": 0.000473176473}, + {"name": "cup (US)", "symbol": "cup (US)", "baseUnit": "cubic meter", "factor": 0.000236588236}, + {"name": "fluid ounce (US)", "symbol": "fl oz (US)", "baseUnit": "cubic meter", "factor": 0.000029573529}, + {"name": "tablespoon (US)", "symbol": "tbsp (US)", "baseUnit": "cubic meter", "factor": 0.000014786764}, + {"name": "teaspoon (US)", "symbol": "tsp (US)", "baseUnit": "cubic meter", "factor": 0.000004928921}, + {"name": "barrel (oil)", "symbol": "bbl", "baseUnit": "cubic meter", "factor": 0.158987294928}, + {"name": "bushel (US)", "symbol": "bu (US)", "baseUnit": "cubic meter", "factor": 0.035239070166}, + {"name": "peck (US)", "symbol": "pk (US)", "baseUnit": "cubic meter", "factor": 0.008809767541} +] diff --git a/flutterw b/flutterw index e4b5f02..3f289b4 100755 --- a/flutterw +++ b/flutterw @@ -7,7 +7,7 @@ BUILDCACHE=./.build-container-cache DOCKERFILE=./docker/Dockerfile IMAGE=d4rt-formulas-builder -detect_container(){ +detect_container_manager(){ if [ "$DOCKER" != "" ] then @@ -107,12 +107,17 @@ exec_in_container(){ local SPIOPTIONS=$(spi_options) local GRAPHICOPTIONS=$(graphic_options) local DOCKEROPTIONS=$(docker_options) - mkdir -p $BUILDCACHE + mkdir -p $BUILDCACHE/root-home/.config + mkdir -p $BUILDCACHE/root-home/.local + mkdir -p $BUILDCACHE/sdks-flutter-bin-cache + $DOCKER run \ -it \ --init \ --rm \ + -v $BUILDCACHE/root-home/.config:/root/.config \ + -v $BUILDCACHE/root-home/.local:/root/.local \ $DOCKEROPTIONS \ $GRAPHICOPTIONS \ $SPIOPTIONS \ @@ -125,7 +130,7 @@ exec_in_container(){ } main(){ - detect_container + detect_container_manager if [ "$1" = "--build-container" ]; then build_image diff --git a/lib/database/database_service.dart b/lib/database/database_service.dart index 0bb3759..06dc034 100644 --- a/lib/database/database_service.dart +++ b/lib/database/database_service.dart @@ -12,9 +12,11 @@ extension CorpusDatabaseExtension on FormulasDatabase { for (final element in elements) { try { final parsed = models.parseCorpusElements('[${element.elementText}]'); + print("PARSED:$element"); parsedElements.addAll(parsed); } catch (e) { print('Error parsing database element: $e'); + print("NOT PARSED: $element"); // Skip invalid elements but continue processing others continue; } @@ -33,4 +35,4 @@ extension CorpusDatabaseExtension on FormulasDatabase { await insertFormulaElement(element.toStringLiteral()); } } -} \ No newline at end of file +} diff --git a/lib/defaults/default_corpus.dart b/lib/defaults/default_corpus.dart index e9801e3..b678c75 100644 --- a/lib/defaults/default_corpus.dart +++ b/lib/defaults/default_corpus.dart @@ -18,9 +18,12 @@ Future createDefaultCorpus() async{ Future loadUnits() async { final unitResources = [ + "assets/units/amount.d4rt.units", "assets/units/angle.d4rt.units", "assets/units/area.d4rt.units", + "assets/units/charge.d4rt.units", "assets/units/currency.d4rt.units", + "assets/units/derived.d4rt.units", "assets/units/distance.d4rt.units", "assets/units/elasticity.d4rt.units", "assets/units/electricity.d4rt.units", @@ -28,11 +31,13 @@ Future createDefaultCorpus() async{ "assets/units/frequency.d4rt.units", "assets/units/force.d4rt.units", "assets/units/mass.d4rt.units", + "assets/units/power.d4rt.units", "assets/units/pressure.d4rt.units", "assets/units/scalar.d4rt.units", "assets/units/temperature.d4rt.units", "assets/units/time.d4rt.units", "assets/units/velocity.d4rt.units", + "assets/units/volume.d4rt.units", ]; for (final unitRes in unitResources) {