diff --git a/composite_calculator/.gitignore b/composite_calculator/.gitignore deleted file mode 100644 index ac5aa98..0000000 --- a/composite_calculator/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock -**/doc/api/ -.dart_tool/ -build/ diff --git a/composite_calculator/.metadata b/composite_calculator/.metadata deleted file mode 100644 index ea18fe9..0000000 --- a/composite_calculator/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: "bae5e49bc2a867403c43b2aae2de8f8c33b037e4" - channel: "[user-branch]" - -project_type: package diff --git a/composite_calculator/CHANGELOG.md b/composite_calculator/CHANGELOG.md deleted file mode 100644 index 41cc7d8..0000000 --- a/composite_calculator/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -* TODO: Describe initial release. diff --git a/composite_calculator/LICENSE b/composite_calculator/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/composite_calculator/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/composite_calculator/README.md b/composite_calculator/README.md deleted file mode 100644 index 02fe8ec..0000000 --- a/composite_calculator/README.md +++ /dev/null @@ -1,39 +0,0 @@ - - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. - -## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. diff --git a/composite_calculator/analysis_options.yaml b/composite_calculator/analysis_options.yaml deleted file mode 100644 index a5744c1..0000000 --- a/composite_calculator/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/composite_calculator/lib/calculators/UDFRC_rules_of_mixture_calculator.dart b/composite_calculator/lib/calculators/UDFRC_rules_of_mixture_calculator.dart deleted file mode 100644 index c0daf91..0000000 --- a/composite_calculator/lib/calculators/UDFRC_rules_of_mixture_calculator.dart +++ /dev/null @@ -1,230 +0,0 @@ -import 'package:composite_calculator/utils/matrix_to_list_extension.dart'; -import 'package:linalg/matrix.dart'; - -import '../models/UDFRC_rules_of_mixture_input.dart'; -import '../models/UDFRC_rules_of_mixture_output.dart'; -import '../models/analysis_type.dart'; - -class UDFRCRulesOfMixtureCalculator { - static UDFRCRulesOfMixtureOutput calculate(UDFRCRulesOfMixtureInput input) { - double Vf = input.fiberVolumeFraction; - double ef1 = input.E1_fiber; - double ef2 = input.E2_fiber; - double ef3 = ef2; - double gf12 = input.G12_fiber; - double gf13 = gf12; - double gf23 = ef2 / (2 * (1 + input.nu23_fiber)); - double nuf12 = input.nu12_fiber; - double nuf13 = input.nu12_fiber; - double nuf23 = input.nu23_fiber; - - double Vm = 1 - Vf; - double Em = input.E_matrix; - double num = input.nu_matrix; - double Gm = Em / (2 * (1 + num)); - double em1 = Em; - double em2 = Em; - double em3 = Em; - double gm12 = Gm; - double gm13 = Gm; - double gm23 = Gm; - double num12 = num; - double num13 = num; - double num23 = num; - - Matrix Sf = Matrix([ - [1 / ef1, -nuf12 / ef1, -nuf13 / ef1, 0, 0, 0], - [-nuf12 / ef1, 1 / ef2, -nuf23 / ef2, 0, 0, 0], - [-nuf12 / ef1, -nuf23 / ef2, 1 / ef3, 0, 0, 0], - [0, 0, 0, 1 / gf23, 0, 0], - [0, 0, 0, 0, 1 / gf13, 0], - [0, 0, 0, 0, 0, 1 / gf12] - ]); - Matrix SHf_Temp = Matrix([ - [ef1, nuf12, nuf13, 0, 0, 0], - [ - -nuf12, - 1 / ef2 - nuf12 * nuf12 / ef1, - -nuf23 / ef2 - nuf13 * nuf13 / ef1, - 0, - 0, - 0 - ], - [ - -nuf23, - -nuf23 / ef2 - nuf12 * nuf12 / ef1, - 1 / ef3 - nuf13 * nuf13 / ef1, - 0, - 0, - 0 - ], - [0, 0, 0, 1 / gf23, 0, 0], - [0, 0, 0, 0, 1 / gf13, 0], - [0, 0, 0, 0, 0, 1 / gf12] - ]); - - Matrix Sm = Matrix([ - [1 / em1, -num12 / em1, -num13 / em1, 0, 0, 0], - [-num12 / em1, 1 / em2, -num23 / em2, 0, 0, 0], - [-num12 / em1, -num23 / em2, 1 / em3, 0, 0, 0], - [0, 0, 0, 1 / gm23, 0, 0], - [0, 0, 0, 0, 1 / gm13, 0], - [0, 0, 0, 0, 0, 1 / gm12] - ]); - Matrix SHm_Temp = Matrix([ - [em1, num12, num13, 0, 0, 0], - [ - -num12, - 1 / em2 - num12 * num12 / em1, - -num23 / em2 - num13 * num13 / em1, - 0, - 0, - 0 - ], - [ - -num23, - -num23 / em2 - num12 * num12 / em1, - 1 / em3 - num13 * num13 / em1, - 0, - 0, - 0 - ], - [0, 0, 0, 1 / gm23, 0, 0], - [0, 0, 0, 0, 1 / gm13, 0], - [0, 0, 0, 0, 0, 1 / gm12] - ]); - - Matrix Cf = Sf.inverse(); - Matrix Cm = Sm.inverse(); - - Matrix CVs = Cf * Vf + Cm * Vm; - Matrix SVs = CVs.inverse(); - - Matrix SRs = Sf * Vf + Sm * Vm; - Matrix CRs = SRs.inverse(); - - Matrix SHs_Temp = SHf_Temp * Vf + SHm_Temp * Vm; - - UDFRCRulesOfMixtureOutput output = UDFRCRulesOfMixtureOutput(); - - output.voigtRulesOfMixture.engineeringConstants['E1'] = 1 / SVs[0][0]; - output.voigtRulesOfMixture.engineeringConstants['E2'] = 1 / SVs[1][1]; - output.voigtRulesOfMixture.engineeringConstants['E3'] = 1 / SVs[2][2]; - output.voigtRulesOfMixture.engineeringConstants['G12'] = 1 / SVs[5][5]; - output.voigtRulesOfMixture.engineeringConstants['G13'] = 1 / SVs[4][4]; - output.voigtRulesOfMixture.engineeringConstants['G23'] = 1 / SVs[3][3]; - output.voigtRulesOfMixture.engineeringConstants['nu12'] = - -1 / SVs[0][0] * SVs[0][1]; - output.voigtRulesOfMixture.engineeringConstants['nu13'] = - -1 / SVs[0][0] * SVs[0][2]; - output.voigtRulesOfMixture.engineeringConstants['nu23'] = - -1 / SVs[1][1] * SVs[1][2]; - - output.reussRulesOfMixture.engineeringConstants['E1'] = 1 / SRs[0][0]; - output.reussRulesOfMixture.engineeringConstants['E2'] = 1 / SRs[1][1]; - output.reussRulesOfMixture.engineeringConstants['E3'] = 1 / SRs[2][2]; - output.reussRulesOfMixture.engineeringConstants['G12'] = 1 / SRs[5][5]; - output.reussRulesOfMixture.engineeringConstants['G13'] = 1 / SRs[4][4]; - output.reussRulesOfMixture.engineeringConstants['G23'] = 1 / SRs[3][3]; - output.reussRulesOfMixture.engineeringConstants['nu12'] = - -1 / SRs[0][0] * SRs[0][1]; - output.reussRulesOfMixture.engineeringConstants['nu13'] = - -1 / SRs[0][0] * SRs[0][2]; - output.reussRulesOfMixture.engineeringConstants['nu23'] = - -1 / SRs[1][1] * SRs[1][2]; - - double eh1 = SHs_Temp[0][0]; - - double nuh12 = SHs_Temp[0][1]; - double nuh13 = SHs_Temp[0][2]; - - double gh12 = 1 / SHs_Temp[5][5]; - double gh13 = 1 / SHs_Temp[4][4]; - double gh23 = 1 / SHs_Temp[3][3]; - - double eh2 = 1 / (SHs_Temp[1][1] + nuh12 * nuh12 / eh1); - double eh3 = 1 / (SHs_Temp[2][2] + nuh13 * nuh13 / eh1); - - double nuh23 = -eh2 * (SHs_Temp[1][2] + nuh12 * nuh12 / eh1); - - output.hybirdRulesOfMixture.engineeringConstants['E1'] = eh1; - output.hybirdRulesOfMixture.engineeringConstants['E2'] = eh2; - output.hybirdRulesOfMixture.engineeringConstants['E3'] = eh3; - output.hybirdRulesOfMixture.engineeringConstants['G12'] = gh12; - output.hybirdRulesOfMixture.engineeringConstants['G13'] = gh13; - output.hybirdRulesOfMixture.engineeringConstants['G23'] = gh23; - output.hybirdRulesOfMixture.engineeringConstants['nu12'] = nuh12; - output.hybirdRulesOfMixture.engineeringConstants['nu13'] = nuh13; - output.hybirdRulesOfMixture.engineeringConstants['nu23'] = nuh23; - - Matrix Shs = Matrix([ - [1 / eh1, -nuh12 / eh1, -nuh13 / eh1, 0, 0, 0], - [-nuh12 / eh1, 1 / eh2, -nuh23 / eh2, 0, 0, 0], - [-nuh12 / eh1, -nuh23 / eh2, 1 / eh3, 0, 0, 0], - [0, 0, 0, 1 / gh23, 0, 0], - [0, 0, 0, 0, 1 / gh13, 0], - [0, 0, 0, 0, 0, 1 / gh12] - ]); - - Matrix Chs = Shs.inverse(); - - output.voigtRulesOfMixture.stiffness = CVs.toListOfLists(); - output.voigtRulesOfMixture.compliance = SVs.toListOfLists(); - - output.reussRulesOfMixture.stiffness = CRs.toListOfLists(); - output.reussRulesOfMixture.compliance = SRs.toListOfLists(); - - output.hybirdRulesOfMixture.stiffness = Chs.toListOfLists(); - output.hybirdRulesOfMixture.compliance = Shs.toListOfLists(); - - if (input.analysisType == AnalysisType.thermalElastic) { - double alpha11_f = input.alpha11_fiber; - double alpha22_f = input.alpha22_fiber; - Matrix cteVector_f = Matrix([ - [alpha11_f], - [alpha22_f], - [alpha22_f], - [0], - [0], - [0] - ]); - - double alpha_m = input.alpha_matrix; - Matrix cteVector_m = Matrix([ - [alpha_m], - [alpha_m], - [alpha_m], - [0], - [0], - [0] - ]); - - Matrix alpha_V = - CVs.inverse() * (Cf * Vf * cteVector_f + Cm * Vm * cteVector_m); - Matrix alpha_R = (cteVector_f * Vf + cteVector_m * Vm); - output.voigtRulesOfMixture.engineeringConstants["alpha11"] = - alpha_V[0][0]; - output.voigtRulesOfMixture.engineeringConstants["alpha22"] = - alpha_V[1][0]; - output.voigtRulesOfMixture.engineeringConstants["alpha33"] = - alpha_V[2][0]; - - output.reussRulesOfMixture.engineeringConstants["alpha11"] = - alpha_R[0][0]; - output.reussRulesOfMixture.engineeringConstants["alpha22"] = - alpha_R[1][0]; - output.reussRulesOfMixture.engineeringConstants["alpha33"] = - alpha_R[2][0]; - - double alpha11_h = (Vf * ef1 * alpha11_f + Vm * em1 * alpha_m) / eh1; - output.hybirdRulesOfMixture.engineeringConstants["alpha11"] = alpha11_h; - double alpha22_h = (Vf * (alpha11_f * nuf12 + alpha22_f) + - Vm * alpha_m * (1 + num) - - alpha11_h * nuh12); - output.hybirdRulesOfMixture.engineeringConstants["alpha22"] = alpha22_h; - output.hybirdRulesOfMixture.engineeringConstants["alpha33"] = alpha22_h; - } - - return output; - } -} diff --git a/composite_calculator/lib/calculators/lamina_engineering_constants_calculator.dart b/composite_calculator/lib/calculators/lamina_engineering_constants_calculator.dart deleted file mode 100644 index 4abde1d..0000000 --- a/composite_calculator/lib/calculators/lamina_engineering_constants_calculator.dart +++ /dev/null @@ -1,91 +0,0 @@ -import 'dart:math'; - -import 'package:composite_calculator/models/analysis_type.dart'; -import 'package:composite_calculator/utils/matrix_to_list_extension.dart'; -import 'package:linalg/linalg.dart'; -import 'package:linalg/matrix.dart'; - -import '../models/lamina_engineering_constants_input.dart'; -import '../models/lamina_engineering_constants_output.dart'; - -class LaminaEngineeringConstantsCalculator { - static LaminaEngineeringConstantsOutput calculate( - LaminaEngineeringConstantsInput input) { - double e1 = input.E1; - double e2 = input.E2; - double g12 = input.G12; - double nu12 = input.nu12; - double layupAngle = input.layupAngle; - - double angleRadian = layupAngle * pi / 180; - double s = sin(angleRadian); - double c = cos(angleRadian); - - var S = Matrix([ - [1 / e1, -nu12 / e1, 0], - [-nu12 / e1, 1 / e2, 0], - [0, 0, 1 / g12] - ]); - var Q = S.inverse(); - - Matrix T_epsilon = Matrix([ - [c * c, s * s, -s * c], - [s * s, c * c, s * c], - [2 * s * c, -2 * s * c, c * c - s * s] - ]); - - Matrix T_sigma = Matrix([ - [c * c, s * s, -2 * s * c], - [s * s, c * c, 2 * s * c], - [s * c, -s * c, c * c - s * s] - ]); - - Matrix Q_bar = T_sigma.transpose() * Q * T_sigma; - Matrix S_bar = T_epsilon.transpose() * S * T_epsilon; - - double E_x = 1 / S_bar[0][0]; - double E_y = 1 / S_bar[1][1]; - double G_xy = 1 / S_bar[2][2]; - double nu_xy = -S_bar[0][1] * E_x; - double eta_x_xy = S_bar[2][0] * E_x; - double eta_y_xy = S_bar[2][1] * E_y; - - LaminaEngineeringConstantsOutput output = LaminaEngineeringConstantsOutput( - analysisType: input.analysisType, - E1: E_x, - E2: E_y, - G12: G_xy, - nu12: nu_xy, - eta1_12: eta_x_xy, - eta2_12: eta_y_xy, - Q: Q_bar.toListOfLists(), - S: S_bar.toListOfLists()); - - if (input.analysisType == AnalysisType.thermalElastic) { - double alpha11 = input.alpha11; - double alpha22 = input.alpha22; - double alpha12 = input.alpha12; - - Matrix R_epsilon_e = Matrix([ - [c * c, s * s, -s * c], - [s * s, c * c, s * c], - [2 * s * c, -2 * s * c, c * c - s * s] - ]); - - Matrix cteVector = Matrix([ - [alpha11], - [alpha22], - [2 * alpha12] - ]); - Matrix alpha_p = R_epsilon_e * cteVector; - double alpha_xx = alpha_p[0][0]; - double alpha_yy = alpha_p[1][0]; - double alpha_xy = alpha_p[2][0] / 2; - output.alpha_11 = alpha_xx; - output.alpha_22 = alpha_yy; - output.alpha_12 = alpha_xy; - } - - return output; - } -} diff --git a/composite_calculator/lib/calculators/lamina_stress_strain_calculator.dart b/composite_calculator/lib/calculators/lamina_stress_strain_calculator.dart deleted file mode 100644 index 842fcbe..0000000 --- a/composite_calculator/lib/calculators/lamina_stress_strain_calculator.dart +++ /dev/null @@ -1,130 +0,0 @@ -import 'dart:math'; - -import 'package:composite_calculator/models/analysis_type.dart'; -import 'package:composite_calculator/models/tensor_type.dart'; -import 'package:composite_calculator/utils/matrix_to_list_extension.dart'; -import 'package:linalg/linalg.dart'; -import 'package:linalg/matrix.dart'; - -import '../models/lamina_stress_strain_input.dart'; -import '../models/lamina_stress_strain_output.dart'; - -class LaminaStressStrainCalculator { - static LaminaStressStrainOutput calculate(LaminaStressStrainInput input) { - double e1 = input.E1; - double e2 = input.E2; - double g12 = input.G12; - double nu12 = input.nu12; - double layupAngle = input.layupAngle; - - double alpha11 = input.alpha11; - double alpha22 = input.alpha22; - double alpha12 = input.alpha12; - double deltaT = input.deltaT; - - double angleRadian = layupAngle * pi / 180; - double s = sin(angleRadian); - double c = cos(angleRadian); - - var S = Matrix([ - [1 / e1, -nu12 / e1, 0], - [-nu12 / e1, 1 / e2, 0], - [0, 0, 1 / g12] - ]); - var Q = S.inverse(); - - Matrix T_epsilon = Matrix([ - [c * c, s * s, -s * c], - [s * s, c * c, s * c], - [2 * s * c, -2 * s * c, c * c - s * s] - ]); - - Matrix T_sigma = Matrix([ - [c * c, s * s, -2 * s * c], - [s * s, c * c, 2 * s * c], - [s * c, -s * c, c * c - s * s] - ]); - - Matrix Q_bar = T_sigma.transpose() * Q * T_sigma; - Matrix S_bar = T_epsilon.transpose() * S * T_epsilon; - - TensorType tensorType = input.tensorType; - AnalysisType analysisType = input.analysisType; - - if (tensorType == TensorType.stress) { - double sigma11 = input.sigma11; - double sigma22 = input.sigma22; - double sigma12 = input.sigma12; - var stressVector = Matrix([ - [sigma11], - [sigma22], - [sigma12] - ]); - - Matrix strainVector; - if (analysisType == AnalysisType.elastic) { - strainVector = S_bar * stressVector; - } else { - double alpha11DeltaT = alpha11 * deltaT; - double alpha22DeltaT = alpha22 * deltaT; - double alpha12DeltaT = alpha12 * deltaT; - var cteVector = Matrix([ - [alpha11DeltaT], - [alpha22DeltaT], - [2 * alpha12DeltaT] - ]); - var R_epsilon_e = Matrix([ - [c * c, s * s, -s * c], - [s * s, c * c, s * c], - [2 * s * c, -2 * s * c, c * c - s * s] - ]); - strainVector = S_bar * stressVector + R_epsilon_e * cteVector; - } - return LaminaStressStrainOutput( - tensorType: TensorType.strain, - epsilon11: strainVector[0][0], - epsilon22: strainVector[1][0], - gamma12: strainVector[2][0], - Q: Q_bar.toListOfLists(), - S: S_bar.toListOfLists(), - ); - } else { - double epsilon11 = input.epsilon11; - double epsilon22 = input.epsilon22; - double gamma12 = input.gamma12; - var strainVector = Matrix([ - [epsilon11], - [epsilon22], - [gamma12] - ]); - - Matrix stressVector; - if (analysisType == AnalysisType.elastic) { - stressVector = Q_bar * strainVector; - } else { - double alpha11DeltaT = alpha11 * deltaT; - double alpha22DeltaT = alpha22 * deltaT; - double alpha12DeltaT = alpha12 * deltaT; - var cteVector = Matrix([ - [alpha11DeltaT], - [alpha22DeltaT], - [2 * alpha12DeltaT] - ]); - var R_epsilon_e = Matrix([ - [c * c, s * s, -s * c], - [s * s, c * c, s * c], - [2 * s * c, -2 * s * c, c * c - s * s] - ]); - stressVector = Q_bar * (strainVector - R_epsilon_e * cteVector); - } - return LaminaStressStrainOutput( - tensorType: TensorType.stress, - sigma11: stressVector[0][0], - sigma22: stressVector[1][0], - sigma12: stressVector[2][0], - Q: Q_bar.toListOfLists(), - S: S_bar.toListOfLists(), - ); - } - } -} diff --git a/composite_calculator/lib/calculators/laminar_stress_strain_calculator.dart b/composite_calculator/lib/calculators/laminar_stress_strain_calculator.dart deleted file mode 100644 index 8eece34..0000000 --- a/composite_calculator/lib/calculators/laminar_stress_strain_calculator.dart +++ /dev/null @@ -1,156 +0,0 @@ -import 'dart:math'; - -import 'package:composite_calculator/models/tensor_type.dart'; -import 'package:linalg/matrix.dart'; - -import '../models/laminar_stress_strain_input.dart'; -import '../models/laminar_stress_strain_output.dart'; -import '../utils/layup_parser.dart'; - -class LaminarStressStrainCalculator { - static LaminarStressStrainOutput calculate(LaminarStressStrainInput input) { - Matrix A = Matrix.fill(3, 3); - Matrix B = Matrix.fill(3, 3); - Matrix D = Matrix.fill(3, 3); - double thickness = input.layerThickness; - List layups = LayupParser.parse(input.layupSequence) ?? []; - int nPly = layups.length; - double e1 = input.E1; - double e2 = input.E2; - double g12 = input.G12; - double nu12 = input.nu12; - - List bzi = []; - List Q = []; - for (int i = 1; i <= nPly; i++) { - double bz = (-(nPly + 1) * thickness) / 2 + i * thickness; - bzi.add(bz); - } - - for (int i = 0; i < nPly; i++) { - double layup = layups[i]; - - double angleRadian = layup * pi / 180; - double s = sin(angleRadian); - double c = cos(angleRadian); - - Matrix Sep = Matrix([ - [1 / e1, -nu12 / e1, 0], - [-nu12 / e1, 1 / e2, 0], - [0, 0, 1 / g12] - ]); - - Matrix Qep = Sep.inverse(); - - Matrix Rsigmae = Matrix([ - [c * c, s * s, -2 * s * c], - [s * s, c * c, 2 * s * c], - [s * c, -s * c, c * c - s * s] - ]); - - Matrix Qe = Rsigmae * Qep * Rsigmae.transpose(); - - Q.add(Qe); - - A += Qe * thickness; - B += Qe * thickness * bzi[i]; - D += Qe * (thickness * bzi[i] * bzi[i] + pow(thickness, 3) / 12); - } - - Matrix ABD = Matrix([ - [A[0][0], A[0][1], A[0][2], B[0][0], B[0][1], B[0][2]], - [A[1][0], A[1][1], A[1][2], B[1][0], B[1][1], B[1][2]], - [A[2][0], A[2][1], A[2][2], B[2][0], B[2][1], B[2][2]], - [B[0][0], B[0][1], B[0][2], D[0][0], D[0][1], D[0][2]], - [B[1][0], B[1][1], B[1][2], D[1][0], D[1][1], D[1][2]], - [B[2][0], B[2][1], B[2][2], D[2][0], D[2][1], D[2][2]] - ]); - - Matrix ABD_inverese = ABD.inverse(); - - LaminarStressStrainOutput output; - if (input.tensorType == TensorType.stress) { - Matrix stressVector = Matrix([ - [input.N11], - [input.N22], - [input.N12], - [input.M11], - [input.M22], - [input.M12], - ]); - Matrix strainVector = ABD_inverese * stressVector; - output = LaminarStressStrainOutput( - tensorType: TensorType.strain, - epsilon11: strainVector[0][0], - epsilon22: strainVector[1][0], - epsilon12: strainVector[2][0], - kappa11: strainVector[3][0], - kappa22: strainVector[4][0], - kappa12: strainVector[5][0]); - } else { - Matrix strainVector = Matrix([ - [input.epsilon11], - [input.epsilon22], - [input.epsilon12], - [input.kappa11], - [input.kappa22], - [input.kappa12] - ]); - Matrix stressVector = ABD * strainVector; - output = LaminarStressStrainOutput( - tensorType: TensorType.stress, - N11: stressVector[0][0], - N22: stressVector[1][0], - N12: stressVector[2][0], - M11: stressVector[3][0], - M22: stressVector[4][0], - M12: stressVector[5][0]); - } - - return output; - } - - static List getQMatrices(LaminarStressStrainInput input) { - double thickness = input.layerThickness; - List layups = LayupParser.parse(input.layupSequence) ?? []; - int nPly = layups.length; - double e1 = input.E1; - double e2 = input.E2; - double g12 = input.G12; - double nu12 = input.nu12; - - List bzi = []; - List Q = []; - for (int i = 1; i <= nPly; i++) { - double bz = (-(nPly + 1) * thickness) / 2 + i * thickness; - bzi.add(bz); - } - - for (int i = 0; i < nPly; i++) { - double layup = layups[i]; - - double angleRadian = layup * pi / 180; - double s = sin(angleRadian); - double c = cos(angleRadian); - - Matrix Sep = Matrix([ - [1 / e1, -nu12 / e1, 0], - [-nu12 / e1, 1 / e2, 0], - [0, 0, 1 / g12] - ]); - - Matrix Qep = Sep.inverse(); - - Matrix Rsigmae = Matrix([ - [c * c, s * s, -2 * s * c], - [s * s, c * c, 2 * s * c], - [s * c, -s * c, c * c - s * s] - ]); - - Matrix Qe = Rsigmae * Qep * Rsigmae.transpose(); - - Q.add(Qe); - } - return Q; - } -} diff --git a/composite_calculator/lib/calculators/laminate_3d_properties_calculator.dart b/composite_calculator/lib/calculators/laminate_3d_properties_calculator.dart deleted file mode 100644 index 4ae70e3..0000000 --- a/composite_calculator/lib/calculators/laminate_3d_properties_calculator.dart +++ /dev/null @@ -1,122 +0,0 @@ -import 'dart:math'; - -import 'package:composite_calculator/composite_calculator.dart'; -import 'package:composite_calculator/utils/layup_parser.dart'; -import 'package:composite_calculator/utils/matrix_to_list_extension.dart'; -import 'package:linalg/linalg.dart'; -import 'package:linalg/matrix.dart'; - -import '../models/laminate_3d_properties_input.dart'; -import '../models/laminate_3d_properties_output.dart'; - -class Laminate3DPropertiesCalculator { - static Laminate3DPropertiesOutput calculate( - Laminate3DPropertiesInput input) { - double thickness = input.layerThickness; - List layups = LayupParser.parse(input.layupSequence) ?? []; - int nPly = layups.length; - double e1 = input.E1; - double e2 = input.E2; - double g12 = input.G12; - double nu12 = input.nu12; - double nu23 = input.nu23; - double e3 = e2; - double g13 = g12; - double g23 = e2 / (2 * (1 + nu23)); - double nu13 = nu12; - - List bzi = []; - for (int i = 1; i <= nPly; i++) { - double bz = (-(nPly + 1) * thickness) / 2 + i * thickness; - bzi.add(bz); - } - - Matrix C = Matrix.fill(6, 6); - Matrix alpha_temp = Matrix.fill(3, 1); - Matrix Q_start = Matrix.fill(3, 3); - - for (int i = 0; i < nPly; i++) { - double layup = layups[i]; - - double angleRadian = layup * pi / 180; - double s = sin(angleRadian); - double c = cos(angleRadian); - Matrix Sp = Matrix([ - [1 / e1, -nu12 / e1, -nu13 / e1, 0, 0, 0], - [-nu12 / e1, 1 / e2, -nu23 / e2, 0, 0, 0], - [-nu13 / e1, -nu23 / e2, 1 / e3, 0, 0, 0], - [0, 0, 0, 1 / g23, 0, 0], - [0, 0, 0, 0, 1 / g13, 0], - [0, 0, 0, 0, 0, 1 / g12] - ]); - - Matrix Cp = Sp.inverse(); - - Matrix Rsigma = Matrix([ - [c * c, s * s, 0, 0, 0, -2 * s * c], - [s * s, c * c, 0, 0, 0, 2 * s * c], - [0, 0, 1, 0, 0, 0], - [0, 0, 0, c, s, 0], - [0, 0, 0, -s, c, 0], - [s * c, -s * c, 0, 0, 0, c * c - s * s] - ]); - Matrix C_single = Rsigma * Cp * Rsigma.transpose(); - C += C_single; - - if (input.analysisType == AnalysisType.thermalElastic) { - double alpha11 = input.alpha11; - double alpha22 = input.alpha22; - double alpha12 = input.alpha12; - Matrix cteVector = Matrix([ - [alpha11], - [alpha22], - [2 * alpha12] - ]); - Matrix S_single = C_single.inverse(); - Matrix Se = Matrix([ - [S_single[0][0], S_single[0][1], S_single[0][5]], - [S_single[0][1], S_single[1][1], S_single[1][5]], - [S_single[0][5], S_single[1][5], S_single[5][5]] - ]); - Matrix Q = Se.inverse(); - Q_start += Q; - - Matrix R_epsilon_e = Matrix([ - [c * c, s * s, -s * c], - [s * s, c * c, s * c], - [2 * s * c, -2 * s * c, c * c - s * s] - ]); - - alpha_temp += Q * R_epsilon_e * cteVector; - } - } - - C = C * (1 / nPly); - Matrix S = C.inverse(); - - Laminate3DPropertiesOutput output = Laminate3DPropertiesOutput(); - output.stiffness = C.toListOfLists(); - output.compliance = S.toListOfLists(); - - output.engineeringConstants["E1"] = 1 / S[0][0]; - output.engineeringConstants["E2"] = 1 / S[1][1]; - output.engineeringConstants["E3"] = 1 / S[2][2]; - output.engineeringConstants["G12"] = 1 / S[5][5]; - output.engineeringConstants["G13"] = 1 / S[4][4]; - output.engineeringConstants["G23"] = 1 / S[3][3]; - output.engineeringConstants["nu12"] = -1 / S[0][0] * S[0][1]; - output.engineeringConstants["nu13"] = -1 / S[0][0] * S[0][2]; - output.engineeringConstants["nu23"] = -1 / S[1][1] * S[1][2]; - - if (input.analysisType == AnalysisType.thermalElastic) { - Q_start = Q_start * (1 / nPly); - alpha_temp = alpha_temp * (1 / nPly); - Matrix alpha_CTE = Q_start.inverse() * alpha_temp; - output.engineeringConstants["alpha11"] = alpha_CTE[0][0]; - output.engineeringConstants["alpha22"] = alpha_CTE[1][0]; - output.engineeringConstants["alpha12"] = alpha_CTE[2][0]; - } - - return output; - } -} diff --git a/composite_calculator/lib/calculators/laminate_plate_properties_calculator.dart b/composite_calculator/lib/calculators/laminate_plate_properties_calculator.dart deleted file mode 100644 index 802d4ba..0000000 --- a/composite_calculator/lib/calculators/laminate_plate_properties_calculator.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'dart:math'; - -import 'package:composite_calculator/composite_calculator.dart'; -import 'package:composite_calculator/models/in-plane-properties.dart'; -import 'package:composite_calculator/utils/layup_parser.dart'; -import 'package:composite_calculator/utils/matrix_to_list_extension.dart'; -import 'package:linalg/linalg.dart'; -import 'package:linalg/matrix.dart'; - -import '../models/laminate_plate_properties_input.dart'; -import '../models/laminate_plate_properties_output.dart'; - -class LaminatePlatePropertiesCalculator { - static LaminatePlatePropertiesOutput calculate( - LaminatePlatePropertiesInput input) { - Matrix A = Matrix.fill(3, 3); - Matrix B = Matrix.fill(3, 3); - Matrix D = Matrix.fill(3, 3); - - double e1 = input.E1; - double e2 = input.E2; - double g12 = input.G12; - double nu12 = input.nu12; - double thickness = input.layerThickness; - String layupSequence = input.layupSequence; - List layups = LayupParser.parse(layupSequence) ?? []; - int nPly = layups.length; - - List bzi = []; - for (int i = 1; i <= nPly; i++) { - double bz = (-(nPly + 1) * thickness) / 2 + i * thickness; - bzi.add(bz); - } - for (int i = 0; i < nPly; i++) { - double layup = layups[i]; - - double angleRadian = layup * pi / 180; - double s = sin(angleRadian); - double c = cos(angleRadian); - - Matrix Sep = Matrix([ - [1 / e1, -nu12 / e1, 0], - [-nu12 / e1, 1 / e2, 0], - [0, 0, 1 / g12] - ]); - - Matrix Qep = Sep.inverse(); - - Matrix Rsigmae = Matrix([ - [c * c, s * s, -2 * s * c], - [s * s, c * c, 2 * s * c], - [s * c, -s * c, c * c - s * s] - ]); - - Matrix Qe = Rsigmae * Qep * Rsigmae.transpose(); - - A += Qe * thickness; - B += Qe * thickness * bzi[i]; - D += Qe * (thickness * bzi[i] * bzi[i] + pow(thickness, 3) / 12); - } - - LaminatePlatePropertiesOutput output = LaminatePlatePropertiesOutput( - A: A.toListOfLists(), - B: B.toListOfLists(), - D: D.toListOfLists(), - ); - - double h = nPly * thickness; - - Matrix Ses = A.inverse() * h; - Matrix Sesf = D.inverse() * (pow(h, 3) / 12); - - output.inPlaneProperties = InPlaneProperties( - analysisType: input.analysisType, - E1: 1 / Ses[0][0], - E2: 1 / Ses[1][1], - G12: 1 / Ses[2][2], - nu12: -1 / Ses[0][0] * Ses[0][1], - eta121: -1 / Ses[2][2] * Ses[0][2], - eta122: -1 / Ses[2][2] * Ses[1][2], - ); - - output.flexuralProperties = InPlaneProperties( - analysisType: input.analysisType, - E1: 1 / Sesf[0][0], - E2: 1 / Sesf[1][1], - G12: 1 / Sesf[2][2], - nu12: -1 / Sesf[0][0] * Sesf[0][1], - eta121: -1 / Sesf[2][2] * Sesf[0][2], - eta122: -1 / Sesf[2][2] * Sesf[1][2], - ); - - if (input.analysisType == AnalysisType.thermalElastic) { - double alpha11 = input.alpha11; - double alpha22 = input.alpha22; - double alpha12 = input.alpha12; - - Matrix temp_eff = Matrix.fill(3, 1); - Matrix temp_flex = Matrix.fill(3, 1); - - for (int i = 0; i < nPly; i++) { - double layup = layups[i]; - - double angleRadian = layup * pi / 180; - double s = sin(angleRadian); - double c = cos(angleRadian); - - Matrix Sep = Matrix([ - [1 / e1, -nu12 / e1, 0], - [-nu12 / e1, 1 / e2, 0], - [0, 0, 1 / g12] - ]); - - Matrix Qep = Sep.inverse(); - - Matrix Rsigmae = Matrix([ - [c * c, s * s, -2 * s * c], - [s * s, c * c, 2 * s * c], - [s * c, -s * c, c * c - s * s] - ]); - - Matrix Qe = Rsigmae * Qep * Rsigmae.transpose(); - - Matrix R_epsilon_e = Matrix([ - [c * c, s * s, -s * c], - [s * s, c * c, s * c], - [2 * s * c, -2 * s * c, c * c - s * s] - ]); - - Matrix cteVector = Matrix([ - [alpha11], - [alpha22], - [2 * alpha12] - ]); - - temp_eff += Qe * R_epsilon_e * cteVector * thickness; - temp_flex += Qe * - R_epsilon_e * - cteVector * - (thickness * bzi[i] * bzi[i] + - thickness * thickness * thickness / 12); - } - - Matrix cteVector_effective = A.inverse() * temp_eff; - Matrix cteVector_flexural = D.inverse() * temp_flex; - - output.inPlaneProperties.alpha11 = cteVector_effective[0][0]; - output.inPlaneProperties.alpha22 = cteVector_effective[1][0]; - output.inPlaneProperties.alpha12 = cteVector_effective[2][0]; - - output.flexuralProperties.alpha11 = cteVector_flexural[0][0]; - output.flexuralProperties.alpha22 = cteVector_flexural[1][0]; - output.flexuralProperties.alpha12 = cteVector_flexural[2][0]; - } - - return output; - } -} diff --git a/composite_calculator/lib/composite_calculator.dart b/composite_calculator/lib/composite_calculator.dart deleted file mode 100644 index a1da23d..0000000 --- a/composite_calculator/lib/composite_calculator.dart +++ /dev/null @@ -1,21 +0,0 @@ -export 'models/analysis_type.dart'; - -export 'models/lamina_engineering_constants_input.dart'; -export 'models/lamina_engineering_constants_output.dart'; -export 'models/lamina_stress_strain_input.dart'; -export 'models/lamina_stress_strain_output.dart'; -export 'models/laminate_plate_properties_input.dart'; -export 'models/laminate_plate_properties_output.dart'; -export 'models/laminate_3d_properties_input.dart'; -export 'models/laminate_3d_properties_output.dart'; -export 'models/laminar_stress_strain_input.dart'; -export 'models/laminar_stress_strain_output.dart'; -export 'models/UDFRC_rules_of_mixture_input.dart'; -export 'models/UDFRC_rules_of_mixture_output.dart'; - -export 'calculators/lamina_engineering_constants_calculator.dart'; -export 'calculators/lamina_stress_strain_calculator.dart'; -export 'calculators/laminate_plate_properties_calculator.dart'; -export 'calculators/laminate_3d_properties_calculator.dart'; -export 'calculators/laminar_stress_strain_calculator.dart'; -export 'calculators/UDFRC_rules_of_mixture_calculator.dart'; diff --git a/composite_calculator/lib/models/UDFRC_rules_of_mixture_input.dart b/composite_calculator/lib/models/UDFRC_rules_of_mixture_input.dart deleted file mode 100644 index cc3a31e..0000000 --- a/composite_calculator/lib/models/UDFRC_rules_of_mixture_input.dart +++ /dev/null @@ -1,84 +0,0 @@ -import 'package:composite_calculator/models/analysis_type.dart'; - -class UDFRCRulesOfMixtureInput { - AnalysisType analysisType; - double E1_fiber; - double E2_fiber; - double G12_fiber; - double nu12_fiber; - double nu23_fiber; - double alpha11_fiber; - double alpha22_fiber; - double E_matrix; - double nu_matrix; - double alpha_matrix; - double fiberVolumeFraction; - - UDFRCRulesOfMixtureInput({ - this.analysisType = AnalysisType.elastic, - this.E1_fiber = 0, - this.E2_fiber = 0, - this.G12_fiber = 0, - this.nu12_fiber = 0, - this.nu23_fiber = 0, - this.alpha11_fiber = 0, - this.alpha22_fiber = 0, - this.E_matrix = 0, - this.nu_matrix = 0, - this.alpha_matrix = 0, - this.fiberVolumeFraction = 0, - }); - - // Factory method to create an instance with default values - factory UDFRCRulesOfMixtureInput.withDefaults() { - return UDFRCRulesOfMixtureInput( - E1_fiber: 150000, - E2_fiber: 10000, - G12_fiber: 5000, - nu12_fiber: 0.3, - nu23_fiber: 0.25, - E_matrix: 3500, - nu_matrix: 0.35, - fiberVolumeFraction: 0.3 - ); - } - - Map toJson() { - return { - 'analysis_type': analysisType.toJson(), - 'E1_fiber': E1_fiber, - 'E2_fiber': E2_fiber, - 'G12_fiber': G12_fiber, - 'nu12_fiber': nu12_fiber, - 'nu23_fiber': nu23_fiber, - 'alpha11_fiber': alpha11_fiber, - 'alpha22_fiber': alpha22_fiber, - 'E_matrix': E_matrix, - 'nu_matrix': nu_matrix, - 'alpha_matrix': alpha_matrix, - 'fiberVolumeFraction': fiberVolumeFraction, - }; - } - - // Factory method to create an instance from a JSON map - factory UDFRCRulesOfMixtureInput.fromJson(Map json) { - return UDFRCRulesOfMixtureInput( - analysisType: AnalysisType.values.firstWhere( - (e) => - e.toString() == - 'AnalysisType.' + (json['analysis_type'] ?? "elastic"), - orElse: () => AnalysisType.elastic, // Default value if not found - ), - E1_fiber: (json['E1_fiber'] ?? 0).toDouble(), - E2_fiber: (json['E2_fiber'] ?? 0).toDouble(), - G12_fiber: (json['G12_fiber'] ?? 0).toDouble(), - nu12_fiber: (json['nu12_fiber'] ?? 0).toDouble(), - alpha11_fiber: (json['alpha11_fiber'] ?? 0).toDouble(), - alpha22_fiber: (json['alpha22_fiber'] ?? 0).toDouble(), - E_matrix: (json['E_matrix'] ?? 0).toDouble(), - nu_matrix: (json['nu_matrix'] ?? 0).toDouble(), - alpha_matrix: (json['alpha_matrix'] ?? 0).toDouble(), - fiberVolumeFraction: (json['fiberVolumeFraction'] ?? 0).toDouble(), - ); - } -} diff --git a/composite_calculator/lib/models/UDFRC_rules_of_mixture_output.dart b/composite_calculator/lib/models/UDFRC_rules_of_mixture_output.dart deleted file mode 100644 index 830b90d..0000000 --- a/composite_calculator/lib/models/UDFRC_rules_of_mixture_output.dart +++ /dev/null @@ -1,46 +0,0 @@ -class UDFRCRulesOfMixtureOutput { - ThreeDimensionalPropertiesOutput voigtRulesOfMixture; - ThreeDimensionalPropertiesOutput reussRulesOfMixture; - ThreeDimensionalPropertiesOutput hybirdRulesOfMixture; - - UDFRCRulesOfMixtureOutput({ - ThreeDimensionalPropertiesOutput? voigtRulesOfMixture, - ThreeDimensionalPropertiesOutput? reussRulesOfMixture, - ThreeDimensionalPropertiesOutput? hybridRulesOfMixture, - }) : voigtRulesOfMixture = - voigtRulesOfMixture ?? ThreeDimensionalPropertiesOutput(), - reussRulesOfMixture = - reussRulesOfMixture ?? ThreeDimensionalPropertiesOutput(), - hybirdRulesOfMixture = - hybridRulesOfMixture ?? ThreeDimensionalPropertiesOutput(); - - Map toJson() { - return { - 'voigtRulesOfMixture': voigtRulesOfMixture.toJson(), - 'reussRulesOfMixture': reussRulesOfMixture.toJson(), - 'hybridRulesOfMixture': hybirdRulesOfMixture.toJson() - }; - } -} - -class ThreeDimensionalPropertiesOutput { - List> stiffness; - List> compliance; - - Map engineeringConstants; - - ThreeDimensionalPropertiesOutput({ - this.stiffness = const [], - this.compliance = const [], - Map? - engineeringConstants, // Make it nullable and initialize later - }) : engineeringConstants = engineeringConstants ?? {}; - - Map toJson() { - return { - 'stiffness': stiffness, - 'compliance': compliance, - 'engineeringConstants': engineeringConstants - }; - } -} diff --git a/composite_calculator/lib/models/analysis_type.dart b/composite_calculator/lib/models/analysis_type.dart deleted file mode 100644 index d08106b..0000000 --- a/composite_calculator/lib/models/analysis_type.dart +++ /dev/null @@ -1,23 +0,0 @@ -enum AnalysisType { - elastic, - thermalElastic; - - // Method to convert enum to JSON-friendly string - String toJson() { - switch (this) { - case AnalysisType.elastic: - return 'elastic'; - case AnalysisType.thermalElastic: - return 'thermalElastic'; - } - } - - String get name { - switch (this) { - case AnalysisType.elastic: - return 'Elastic'; - case AnalysisType.thermalElastic: - return 'Thermal elastic'; - } - } -} diff --git a/composite_calculator/lib/models/in-plane-properties.dart b/composite_calculator/lib/models/in-plane-properties.dart deleted file mode 100644 index 6bd3f29..0000000 --- a/composite_calculator/lib/models/in-plane-properties.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'analysis_type.dart'; - -class InPlaneProperties { - AnalysisType analysisType; - double E1; - double E2; - double G12; - double nu12; - double eta121; - double eta122; - double alpha11; - double alpha22; - double alpha12; - - InPlaneProperties({ - this.analysisType = AnalysisType.elastic, - this.E1 = 0, - this.E2 = 0, - this.G12 = 0, - this.nu12 = 0, - this.eta121 = 0, - this.eta122 = 0, - this.alpha11 = 0, - this.alpha22 = 0, - this.alpha12 = 0, - }); - - Map toJson() { - Map result = { - 'E1': E1, - 'E2': E2, - 'G12': G12, - 'nu12': nu12, - 'eta121': eta121, - 'eta122': eta122, - }; - if (analysisType == AnalysisType.thermalElastic) { - result.addAll({ - 'alpha11': alpha11, - 'alpha22': alpha22, - 'alpha12': alpha12, - }); - } - return result; - } -} diff --git a/composite_calculator/lib/models/lamina_engineering_constants_input.dart b/composite_calculator/lib/models/lamina_engineering_constants_input.dart deleted file mode 100644 index d40db6b..0000000 --- a/composite_calculator/lib/models/lamina_engineering_constants_input.dart +++ /dev/null @@ -1,71 +0,0 @@ -import 'package:composite_calculator/models/analysis_type.dart'; - -class LaminaEngineeringConstantsInput { - AnalysisType analysisType; - double E1; - double E2; - double G12; - double nu12; - double layupAngle; - - double alpha11; - double alpha22; - double alpha12; - - LaminaEngineeringConstantsInput({ - this.analysisType = AnalysisType.elastic, - this.E1 = 0, - this.E2 = 0, - this.G12 = 0, - this.nu12 = 0, - this.layupAngle = 0, - this.alpha11 = 0, - this.alpha22 = 0, - this.alpha12 = 0, - }); - - // Factory method to create an instance with default values - factory LaminaEngineeringConstantsInput.withDefaults() { - return LaminaEngineeringConstantsInput( - E1: 150000, - E2: 10000, - G12: 5000, - nu12: 0.3, - layupAngle: 45, - ); - } - - Map toJson() { - return { - 'analysis_type': analysisType.toJson(), - 'E1': E1, - 'E2': E2, - 'G12': G12, - 'nu12': nu12, - 'layup_angle': layupAngle, - 'alpha11': alpha11, - 'alpha22': alpha22, - 'alpha12': alpha12, - }; - } - - // Factory method to create an instance from a JSON map - factory LaminaEngineeringConstantsInput.fromJson(Map json) { - return LaminaEngineeringConstantsInput( - analysisType: AnalysisType.values.firstWhere( - (e) => - e.toString() == - 'AnalysisType.' + (json['analysis_type'] ?? "elastic"), - orElse: () => AnalysisType.elastic, // Default value if not found - ), - E1: (json['E1'] ?? 0).toDouble(), - E2: (json['E2'] ?? 0).toDouble(), - G12: (json['G12'] ?? 0).toDouble(), - nu12: (json['nu12'] ?? 0).toDouble(), - layupAngle: (json['layup_angle'] ?? 0).toDouble(), - alpha11: (json['alpha11'] ?? 0).toDouble(), - alpha22: (json['alpha22'] ?? 0).toDouble(), - alpha12: (json['alpha12'] ?? 0).toDouble(), - ); - } -} diff --git a/composite_calculator/lib/models/lamina_engineering_constants_output.dart b/composite_calculator/lib/models/lamina_engineering_constants_output.dart deleted file mode 100644 index cdb5dda..0000000 --- a/composite_calculator/lib/models/lamina_engineering_constants_output.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:composite_calculator/models/analysis_type.dart'; - -class LaminaEngineeringConstantsOutput { - AnalysisType analysisType; - - double E1; - double E2; - double G12; - double nu12; - double eta1_12; - double eta2_12; - List> Q; - List> S; - - double alpha_11 = 0; - double alpha_22 = 0; - double alpha_12 = 0; - - LaminaEngineeringConstantsOutput({ - this.analysisType = AnalysisType.elastic, - this.E1 = 0, - this.E2 = 0, - this.G12 = 0, - this.nu12 = 0, - this.eta1_12 = 0, - this.eta2_12 = 0, - List>? Q, // Make it nullable and initialize later - List>? S, // Make it nullable and initialize later - this.alpha_11 = 0, - this.alpha_22 = 0, - this.alpha_12 = 0, - }) : Q = Q ?? [], - S = S ?? []; - - Map toJson() { - Map result = { - 'analysis_type': analysisType.toJson(), - 'E_1': E1, - 'E_2': E2, - 'G_12': G12, - 'nu_12': nu12, - 'eta_1_12': eta1_12, - 'eta_2_12': eta2_12, - 'Q': Q, - 'S': S, - }; - if (analysisType == AnalysisType.thermalElastic) { - result.addAll({ - 'alpha_11': alpha_11, - 'alpha_22': alpha_22, - 'alpha_12': alpha_12, - }); - } - return result; - } -} diff --git a/composite_calculator/lib/models/lamina_stress_strain_input.dart b/composite_calculator/lib/models/lamina_stress_strain_input.dart deleted file mode 100644 index c7587b2..0000000 --- a/composite_calculator/lib/models/lamina_stress_strain_input.dart +++ /dev/null @@ -1,111 +0,0 @@ -import 'package:composite_calculator/models/analysis_type.dart'; -import 'package:composite_calculator/models/tensor_type.dart'; - -class LaminaStressStrainInput { - AnalysisType analysisType; - double E1; - double E2; - double G12; - double nu12; - double layupAngle; - - double alpha11; - double alpha22; - double alpha12; - double deltaT; - - TensorType tensorType; - - double sigma11; - double sigma22; - double sigma12; - - double epsilon11; - double epsilon22; - double gamma12; - - LaminaStressStrainInput({ - this.analysisType = AnalysisType.elastic, - this.E1 = 0, - this.E2 = 0, - this.G12 = 0, - this.nu12 = 0, - this.layupAngle = 0, - this.alpha11 = 0, - this.alpha22 = 0, - this.alpha12 = 0, - this.deltaT = 0, - this.tensorType = TensorType.stress, - this.sigma11 = 0, - this.sigma22 = 0, - this.sigma12 = 0, - this.epsilon11 = 0, - this.epsilon22 = 0, - this.gamma12 = 0, - }); - - // Factory method to create an instance with default values - factory LaminaStressStrainInput.withDefaults() { - return LaminaStressStrainInput( - E1: 150000, - E2: 10000, - G12: 5000, - nu12: 0.3, - layupAngle: 45, - sigma11: 0.1, - ); - } - - Map toJson() { - return { - 'analysis_type': analysisType.toJson(), - 'E1': E1, - 'E2': E2, - 'G12': G12, - 'nu12': nu12, - 'layup_angle': layupAngle, - 'alpha11': alpha11, - 'alpha22': alpha22, - 'alpha12': alpha12, - 'deltaT': deltaT, - 'tensorType': tensorType, - 'sigma11': sigma11, - 'sigma22': sigma22, - 'sigma12': sigma12, - 'epsilon11': epsilon11, - 'epsilon22': epsilon22, - 'gamma12': gamma12, - }; - } - - // Factory method to create an instance from a JSON map - factory LaminaStressStrainInput.fromJson(Map json) { - return LaminaStressStrainInput( - analysisType: AnalysisType.values.firstWhere( - (e) => - e.toString() == - 'AnalysisType.' + (json['analysis_type'] ?? 'elastic'), - orElse: () => AnalysisType.elastic, // Default value if not found - ), - E1: (json['E1'] ?? 0).toDouble(), - E2: (json['E2'] ?? 0).toDouble(), - G12: (json['G12'] ?? 0).toDouble(), - nu12: (json['nu12'] ?? 0).toDouble(), - layupAngle: (json['layup_angle'] ?? 0).toDouble(), - alpha11: (json['alpha11'] ?? 0).toDouble(), - alpha22: (json['alpha22'] ?? 0).toDouble(), - alpha12: (json['alpha12'] ?? 0).toDouble(), - deltaT: (json['deltaT'] ?? 0).toDouble(), - tensorType: TensorType.values.firstWhere( - (e) => e.toString() == 'TensorType.' + (json['tensorType'] ?? 'stress'), - orElse: () => TensorType.stress, // Default value if not found - ), - sigma11: (json['sigma11'] ?? 0).toDouble(), - sigma22: (json['sigma22'] ?? 0).toDouble(), - sigma12: (json['sigma12'] ?? 0).toDouble(), - epsilon11: (json['epsilon11'] ?? 0).toDouble(), - epsilon22: (json['epsilon22'] ?? 0).toDouble(), - gamma12: (json['gamma12'] ?? 0).toDouble(), - ); - } -} diff --git a/composite_calculator/lib/models/lamina_stress_strain_output.dart b/composite_calculator/lib/models/lamina_stress_strain_output.dart deleted file mode 100644 index 0472510..0000000 --- a/composite_calculator/lib/models/lamina_stress_strain_output.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'package:composite_calculator/models/analysis_type.dart'; -import 'package:composite_calculator/models/tensor_type.dart'; - -class LaminaStressStrainOutput { - TensorType tensorType; - - double sigma11; - double sigma22; - double sigma12; - - double epsilon11; - double epsilon22; - double gamma12; - - List> Q; - List> S; - - LaminaStressStrainOutput({ - this.tensorType = TensorType.stress, - this.sigma11 = 0, - this.sigma22 = 0, - this.sigma12 = 0, - this.epsilon11 = 0, - this.epsilon22 = 0, - this.gamma12 = 0, - List>? Q, // Make it nullable and initialize later - List>? S, // Make it nullable and initialize later - }) : Q = Q ?? [], - S = S ?? []; - - Map toJson() { - Map result = { - 'Q': Q, - 'S': S, - }; - if (tensorType == TensorType.stress) { - result.addAll({ - 'sigma11': sigma11, - 'sigma22': sigma22, - 'sigma12': sigma12, - }); - } else { - result.addAll({ - 'epsilon11': epsilon11, - 'epsilon22': epsilon22, - 'gamma12': gamma12, - }); - } - return result; - } -} diff --git a/composite_calculator/lib/models/laminar_stress_strain_input.dart b/composite_calculator/lib/models/laminar_stress_strain_input.dart deleted file mode 100644 index c938ab8..0000000 --- a/composite_calculator/lib/models/laminar_stress_strain_input.dart +++ /dev/null @@ -1,116 +0,0 @@ -import 'package:composite_calculator/models/tensor_type.dart'; - -import 'analysis_type.dart'; - -class LaminarStressStrainInput { - double E1; - double E2; - double G12; - double nu12; - String layupSequence; - double layerThickness; - - TensorType tensorType; - - double N11; - double N22; - double N12; - double M11; - double M22; - double M12; - - double epsilon11; - double epsilon22; - double epsilon12; - double kappa11; - double kappa22; - double kappa12; - - LaminarStressStrainInput({ - this.E1 = 0, - this.E2 = 0, - this.G12 = 0, - this.nu12 = 0, - this.layupSequence = "", - this.layerThickness = 0, - this.tensorType = TensorType.stress, - this.N11 = 0, - this.N22 = 0, - this.N12 = 0, - this.M11 = 0, - this.M22 = 0, - this.M12 = 0, - this.epsilon11 = 0, - this.epsilon22 = 0, - this.epsilon12 = 0, - this.kappa11 = 0, - this.kappa22 = 0, - this.kappa12 = 0, - }); - - // Factory method to create an instance with default values - factory LaminarStressStrainInput.withDefaults() { - return LaminarStressStrainInput( - E1: 150000, - E2: 10000, - G12: 5000, - nu12: 0.3, - layupSequence: "[0/90/45/-45]s", - layerThickness: 0.125, - tensorType: TensorType.stress, - N11: 1, - ); - } - - Map toJson() { - return { - 'E1': E1, - 'E2': E2, - 'G12': G12, - 'nu12': nu12, - 'layup_sequence': layupSequence, - 'layer_thickness': layerThickness, - 'tensorType': tensorType, - 'N11': N11, - 'N22': N22, - 'N12': N12, - 'M11': M11, - 'M22': M22, - 'M12': M12, - 'epsilon11': epsilon11, - 'epsilon22': epsilon22, - 'epsilon12': epsilon12, - 'kappa11': kappa11, - 'kappa22': kappa22, - 'kappa12': kappa12, - }; - } - - // Factory method to create an instance from a JSON map - factory LaminarStressStrainInput.fromJson(Map json) { - return LaminarStressStrainInput( - E1: (json['E1'] ?? 0).toDouble(), - E2: (json['E2'] ?? 0).toDouble(), - G12: (json['G12'] ?? 0).toDouble(), - nu12: (json['nu12'] ?? 0).toDouble(), - layupSequence: (json['layup_sequence'] ?? "").toString(), - layerThickness: (json['layer_thickness'] ?? 0).toDouble(), - tensorType: TensorType.values.firstWhere( - (e) => e.toString() == 'TensorType.' + (json['tensorType'] ?? 'stress'), - orElse: () => TensorType.stress, // Default value if not found - ), - N11: (json['N11'] ?? 0).toDouble(), - N22: (json['N22'] ?? 0).toDouble(), - N12: (json['N12'] ?? 0).toDouble(), - M11: (json['M11'] ?? 0).toDouble(), - M22: (json['M22'] ?? 0).toDouble(), - M12: (json['M12'] ?? 0).toDouble(), - epsilon11: (json['epsilon11'] ?? 0).toDouble(), - epsilon22: (json['epsilon22'] ?? 0).toDouble(), - epsilon12: (json['epsilon12'] ?? 0).toDouble(), - kappa11: (json['kappa11'] ?? 0).toDouble(), - kappa22: (json['kappa22'] ?? 0).toDouble(), - kappa12: (json['kappa12'] ?? 0).toDouble(), - ); - } -} diff --git a/composite_calculator/lib/models/laminar_stress_strain_output.dart b/composite_calculator/lib/models/laminar_stress_strain_output.dart deleted file mode 100644 index e5ed243..0000000 --- a/composite_calculator/lib/models/laminar_stress_strain_output.dart +++ /dev/null @@ -1,58 +0,0 @@ -import 'package:composite_calculator/models/tensor_type.dart'; - -class LaminarStressStrainOutput { - TensorType tensorType; - - double N11; - double N22; - double N12; - double M11; - double M22; - double M12; - double epsilon11; - double epsilon22; - double epsilon12; - double kappa11; - double kappa22; - double kappa12; - - LaminarStressStrainOutput({ - this.tensorType = TensorType.stress, - this.N11 = 0, - this.N22 = 0, - this.N12 = 0, - this.M11 = 0, - this.M22 = 0, - this.M12 = 0, - this.epsilon11 = 0, - this.epsilon22 = 0, - this.epsilon12 = 0, - this.kappa11 = 0, - this.kappa22 = 0, - this.kappa12 = 0, - }); - - Map toJson() { - Map result = {}; - if (tensorType == TensorType.stress) { - result.addAll({ - 'N11': N11, - 'N22': N22, - 'N12': N12, - 'M11': M11, - 'M22': M22, - 'M12': M12, - }); - } else { - result.addAll({ - 'epsilon11': epsilon11, - 'epsilon22': epsilon22, - 'epsilon12': epsilon12, - 'kappa11': kappa11, - 'kappa22': kappa22, - 'kappa12': kappa12, - }); - } - return result; - } -} diff --git a/composite_calculator/lib/models/laminate_3d_properties_input.dart b/composite_calculator/lib/models/laminate_3d_properties_input.dart deleted file mode 100644 index 2b2c267..0000000 --- a/composite_calculator/lib/models/laminate_3d_properties_input.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'analysis_type.dart'; - -class Laminate3DPropertiesInput { - AnalysisType analysisType; - double E1; - double E2; - double G12; - double nu12; - double nu23; - String layupSequence; - double layerThickness; - - double alpha11; - double alpha22; - double alpha12; - - Laminate3DPropertiesInput({ - this.analysisType = AnalysisType.elastic, - this.E1 = 0, - this.E2 = 0, - this.G12 = 0, - this.nu12 = 0, - this.nu23 = 0, - this.layupSequence = "", - this.layerThickness = 0, - this.alpha11 = 0, - this.alpha22 = 0, - this.alpha12 = 0, - }); - - // Factory method to create an instance with default values - factory Laminate3DPropertiesInput.withDefaults() { - return Laminate3DPropertiesInput( - E1: 150000, - E2: 10000, - G12: 5000, - nu12: 0.3, - nu23: 0.25, - layupSequence: "[0/90/45/-45]s", - layerThickness: 0.125 - ); - } - - Map toJson() { - return { - 'analysis_type': analysisType.toJson(), - 'E1': E1, - 'E2': E2, - 'G12': G12, - 'nu12': nu12, - 'nu23' : nu23, - 'layup_sequence': layupSequence, - 'layer_thickness': layerThickness, - 'alpha11': alpha11, - 'alpha22': alpha22, - 'alpha12': alpha12, - }; - } - - // Factory method to create an instance from a JSON map - factory Laminate3DPropertiesInput.fromJson(Map json) { - return Laminate3DPropertiesInput( - analysisType: AnalysisType.values.firstWhere( - (e) => - e.toString() == - 'AnalysisType.' + (json['analysis_type'] ?? "elastic"), - orElse: () => AnalysisType.elastic, // Default value if not found - ), - E1: (json['E1'] ?? 0).toDouble(), - E2: (json['E2'] ?? 0).toDouble(), - G12: (json['G12'] ?? 0).toDouble(), - nu12: (json['nu12'] ?? 0).toDouble(), - nu23: (json['nu23'] ?? 0).toDouble(), - layupSequence: (json['layup_sequence'] ?? "").toString(), - layerThickness: (json['layer_thickness'] ?? 0).toDouble(), - alpha11: (json['alpha11'] ?? 0).toDouble(), - alpha22: (json['alpha22'] ?? 0).toDouble(), - alpha12: (json['alpha12'] ?? 0).toDouble(), - ); - } -} \ No newline at end of file diff --git a/composite_calculator/lib/models/laminate_3d_properties_output.dart b/composite_calculator/lib/models/laminate_3d_properties_output.dart deleted file mode 100644 index 5e9a9e2..0000000 --- a/composite_calculator/lib/models/laminate_3d_properties_output.dart +++ /dev/null @@ -1,21 +0,0 @@ -class Laminate3DPropertiesOutput { - List> stiffness; - List> compliance; - - Map engineeringConstants; - - Laminate3DPropertiesOutput({ - this.stiffness = const [], - this.compliance = const [], - Map? - engineeringConstants, // Make it nullable and initialize later - }) : engineeringConstants = engineeringConstants ?? {}; - - Map toJson() { - return { - 'stiffness': stiffness, - 'compliance': compliance, - 'engineeringConstants': engineeringConstants - }; - } -} diff --git a/composite_calculator/lib/models/laminate_plate_properties_input.dart b/composite_calculator/lib/models/laminate_plate_properties_input.dart deleted file mode 100644 index 39c5994..0000000 --- a/composite_calculator/lib/models/laminate_plate_properties_input.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'analysis_type.dart'; - -class LaminatePlatePropertiesInput { - AnalysisType analysisType; - double E1; - double E2; - double G12; - double nu12; - String layupSequence; - double layerThickness; - - double alpha11; - double alpha22; - double alpha12; - - LaminatePlatePropertiesInput({ - this.analysisType = AnalysisType.elastic, - this.E1 = 0, - this.E2 = 0, - this.G12 = 0, - this.nu12 = 0, - this.layupSequence = "", - this.layerThickness = 0, - this.alpha11 = 0, - this.alpha22 = 0, - this.alpha12 = 0, - }); - - // Factory method to create an instance with default values - factory LaminatePlatePropertiesInput.withDefaults() { - return LaminatePlatePropertiesInput( - E1: 150000, - E2: 10000, - G12: 5000, - nu12: 0.3, - layupSequence: "[0/90/45/-45]s", - layerThickness: 0.125 - ); - } - - Map toJson() { - return { - 'analysis_type': analysisType.toJson(), - 'E1': E1, - 'E2': E2, - 'G12': G12, - 'nu12': nu12, - 'layup_sequence': layupSequence, - 'layer_thickness': layerThickness, - 'alpha11': alpha11, - 'alpha22': alpha22, - 'alpha12': alpha12, - }; - } - - // Factory method to create an instance from a JSON map - factory LaminatePlatePropertiesInput.fromJson(Map json) { - return LaminatePlatePropertiesInput( - analysisType: AnalysisType.values.firstWhere( - (e) => - e.toString() == - 'AnalysisType.' + (json['analysis_type'] ?? "elastic"), - orElse: () => AnalysisType.elastic, // Default value if not found - ), - E1: (json['E1'] ?? 0).toDouble(), - E2: (json['E2'] ?? 0).toDouble(), - G12: (json['G12'] ?? 0).toDouble(), - nu12: (json['nu12'] ?? 0).toDouble(), - layupSequence: (json['layup_sequence'] ?? "").toString(), - layerThickness: (json['layer_thickness'] ?? 0).toDouble(), - alpha11: (json['alpha11'] ?? 0).toDouble(), - alpha22: (json['alpha22'] ?? 0).toDouble(), - alpha12: (json['alpha12'] ?? 0).toDouble(), - ); - } -} \ No newline at end of file diff --git a/composite_calculator/lib/models/laminate_plate_properties_output.dart b/composite_calculator/lib/models/laminate_plate_properties_output.dart deleted file mode 100644 index d272527..0000000 --- a/composite_calculator/lib/models/laminate_plate_properties_output.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:composite_calculator/models/in-plane-properties.dart'; - -class LaminatePlatePropertiesOutput { - List> A; - List> B; - List> D; - - InPlaneProperties inPlaneProperties; - InPlaneProperties flexuralProperties; - - LaminatePlatePropertiesOutput({ - this.A = const [], - this.B = const [], - this.D = const [], - InPlaneProperties? inPlaneProperties, - InPlaneProperties? flexuralProperties, - }) : inPlaneProperties = inPlaneProperties ?? InPlaneProperties(), - flexuralProperties = flexuralProperties ?? InPlaneProperties(); - - Map toJson() { - return { - 'A': A, - 'B': B, - 'D': D, - 'in-plane_properties': inPlaneProperties, - 'flexural_properties': flexuralProperties, - }; - } -} diff --git a/composite_calculator/lib/models/tensor_type.dart b/composite_calculator/lib/models/tensor_type.dart deleted file mode 100644 index 5edbc0a..0000000 --- a/composite_calculator/lib/models/tensor_type.dart +++ /dev/null @@ -1,14 +0,0 @@ -enum TensorType { - stress, - strain; - - // Method to convert enum to JSON-friendly string - String toJson() { - switch (this) { - case TensorType.stress: - return 'stress'; - case TensorType.strain: - return 'strain'; - } - } -} diff --git a/composite_calculator/lib/utils/layup_parser.dart b/composite_calculator/lib/utils/layup_parser.dart deleted file mode 100644 index 0e760de..0000000 --- a/composite_calculator/lib/utils/layup_parser.dart +++ /dev/null @@ -1,85 +0,0 @@ -class LayupParser { - static List? parse(String layupSequence) { - List layups = []; - String baseLayup = ""; - int rBefore = 1; - bool symmetry = false; - int rAfter = 1; - - if (layupSequence.split("]").length == 2 && layupSequence.split("]")[1] != "") { - baseLayup = layupSequence.split("]")[0].replaceAll("[", ""); - String msn = layupSequence.split("]")[1]; - if (msn.contains('s')) { - // symmetry - symmetry = true; - var r = msn.split('s'); - - if (r.length == 2) { - if (r[0] != "") { - int? rBeforeTemp = int.tryParse(r[0]); - if (rBeforeTemp != null) { - rBefore = rBeforeTemp; - } else { - return null; - } - } - if (r[1] != "") { - int? rAfterTemp = int.tryParse(r[1]); - if (rAfterTemp != null) { - rAfter = rAfterTemp; - } else { - return null; - } - } - } - } else { - // not symmetry - symmetry = false; - int? rBeforeTemp = int.tryParse(msn); - if (rBeforeTemp != null) { - rBefore = rBeforeTemp; - } else { - return null; - } - } - } else { - baseLayup = layupSequence.replaceAll("[", "").replaceAll("]", ''); - } - - for (String angleString in baseLayup.split('/')) { - double? angle = double.tryParse(angleString); - if (angle == null) { - return null; - } - layups?.add(angle); - } - - var layupsTemp = [...layups!]; - - for (var i = 1; i < rBefore; i++) { - for (var layup in layupsTemp) { - layups?.add(layup); - } - } - - if (layups != null) { - layupsTemp = [...layups]; - } - - if (symmetry) { - var layupsTempReversed = layupsTemp.reversed; - for (var layup in layupsTempReversed) { - layups?.add(layup); - } - } - - layupsTemp = [...layups!]; - - for (var i = 1; i < rAfter; i++) { - for (var layup in layupsTemp) { - layups?.add(layup); - } - } - return layups; - } -} \ No newline at end of file diff --git a/composite_calculator/lib/utils/matrix_to_list_extension.dart b/composite_calculator/lib/utils/matrix_to_list_extension.dart deleted file mode 100644 index d684e52..0000000 --- a/composite_calculator/lib/utils/matrix_to_list_extension.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:linalg/linalg.dart'; - -// Extension on Matrix class to convert it to a List> -extension MatrixToListExtension on Matrix { - List> toListOfLists() { - List> list = []; - for (int i = 0; i < this.m; i++) { - List row = []; - for (int j = 0; j < this.n; j++) { - row.add(this[i][j]); - } - list.add(row); - } - return list; - } -} \ No newline at end of file diff --git a/composite_calculator/pubspec.yaml b/composite_calculator/pubspec.yaml deleted file mode 100644 index 41dab44..0000000 --- a/composite_calculator/pubspec.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: composite_calculator -description: "A new Flutter package project." -version: 0.0.1 -homepage: - -environment: - sdk: '>=3.3.0 <4.0.0' - flutter: ">=1.17.0" - -dependencies: - flutter: - sdk: flutter - linalg: ^0.4.0 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^3.0.0 - test: ^1.16.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/composite_calculator/test/UDFRC_rules_of_mixture_calculator_test.dart b/composite_calculator/test/UDFRC_rules_of_mixture_calculator_test.dart deleted file mode 100644 index 7b72f22..0000000 --- a/composite_calculator/test/UDFRC_rules_of_mixture_calculator_test.dart +++ /dev/null @@ -1,142 +0,0 @@ -import 'package:composite_calculator/calculators/laminate_3d_properties_calculator.dart'; -import 'package:composite_calculator/composite_calculator.dart'; -import 'package:composite_calculator/models/laminate_3d_properties_input.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('UDFRCRulesOfMixtureCalculator Tests', () { - test('Default input test case', () { - // Arrange: Create input data with default values - var input = UDFRCRulesOfMixtureInput.withDefaults(); - - // Act: Calculate the output using the calculator - var output = UDFRCRulesOfMixtureCalculator.calculate(input); - - // Assert: - List> expectedVoigtStiffness = [ - [ - 49663.80608250527, - 3336.796145739233, - 3336.7961457392335, - 0.0, - 0.0, - 0.0 - ], - [ - 3336.7961457392335, - 7164.619090635349, - 2949.8042758205343, - 0.0, - 0.0, - 0.0 - ], - [ - 3336.796145739233, - 2949.8042758205343, - 7164.619090635349, - 0.0, - 0.0, - 0.0 - ], - [0.0, 0.0, 0.0, 2107.4074074074074, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0, 2407.4074074074074, 0.0], - [0.0, 0.0, 0.0, 0.0, 0.0, 2407.4074074074074] - ]; - - List> expectedVoigtCompliance = [ - [ - 2.1069417741194078e-05, - -6.950900645997087e-06, - -6.950900645997087e-06, - 0.0, - 0.0, - 0.0 - ], - [ - -6.950900645997089e-06, - 0.00017035666447795232, - -6.690168350095812e-05, - 0.0, - 0.0, - 0.0 - ], - [ - -6.950900645997084e-06, - -6.690168350095812e-05, - 0.0001703566644779523, - 0.0, - 0.0, - 0.0 - ], - [0.0, 0.0, 0.0, 0.00047451669595782075, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0, 0.00041538461538461537, 0.0], - [0.0, 0.0, 0.0, 0.0, 0.0, 0.00041538461538461537] - ]; - - for (int i = 0; i < output.voigtRulesOfMixture.stiffness.length; i++) { - for (int j = 0; - j < output.voigtRulesOfMixture.stiffness[i].length; - j++) { - expect(output.voigtRulesOfMixture.stiffness[i][j], - closeTo(expectedVoigtStiffness[i][j], 1e-3)); - } - } - for (int i = 0; i < output.voigtRulesOfMixture.compliance.length; i++) { - for (int j = 0; - j < output.voigtRulesOfMixture.compliance[i].length; - j++) { - expect(output.voigtRulesOfMixture.compliance[i][j], - closeTo(expectedVoigtCompliance[i][j], 1e-3)); - } - } - - expect(output.voigtRulesOfMixture.engineeringConstants["E1"], - closeTo(47462.1563957527, 1e-3)); - expect(output.voigtRulesOfMixture.engineeringConstants["E2"], - closeTo(5870.037447988545, 1e-3)); - expect(output.voigtRulesOfMixture.engineeringConstants["E3"], - closeTo(5870.037447988546, 1e-3)); - - expect(output.voigtRulesOfMixture.engineeringConstants["G12"], - closeTo(2407.4074074074074, 1e-3)); - expect(output.voigtRulesOfMixture.engineeringConstants["G13"], - closeTo(2407.4074074074074, 1e-3)); - expect(output.voigtRulesOfMixture.engineeringConstants["G23"], - closeTo(2107.4074074074074, 1e-3)); - - expect(output.voigtRulesOfMixture.engineeringConstants["nu12"], - closeTo(0.32990473355165223, 1e-5)); - expect(output.voigtRulesOfMixture.engineeringConstants["nu13"], - closeTo(0.32990473355165223, 1e-5)); - expect(output.voigtRulesOfMixture.engineeringConstants["nu23"], - closeTo(0.392715387484101, 1e-5)); - }); - - test('Custom input test case', () { - // Arrange: Create custom input data - var input = UDFRCRulesOfMixtureInput( - analysisType: AnalysisType.thermalElastic, - E1_fiber: 150000, - E2_fiber: 10000, - G12_fiber: 5000, - nu12_fiber: 0.3, - nu23_fiber: 0.25, - alpha11_fiber: 0.1, - E_matrix: 3500, - nu_matrix: 0.35, - alpha_matrix: 0.02, - fiberVolumeFraction: 0.3); - - // Act: Calculate the output using the calculator - var output = UDFRCRulesOfMixtureCalculator.calculate(input); - - // Assert: - expect(output.voigtRulesOfMixture.engineeringConstants["alpha11"], - closeTo(9.5829e-2, 1e-3)); - expect(output.voigtRulesOfMixture.engineeringConstants["alpha22"], - closeTo(-3.4089e-3, 1e-3)); - expect(output.voigtRulesOfMixture.engineeringConstants["alpha33"], - closeTo(-3.4089e-3, 1e-3)); - }); - }); -} diff --git a/composite_calculator/test/lamina_engineering_contants_calculator_test.dart b/composite_calculator/test/lamina_engineering_contants_calculator_test.dart deleted file mode 100644 index 35d527d..0000000 --- a/composite_calculator/test/lamina_engineering_contants_calculator_test.dart +++ /dev/null @@ -1,67 +0,0 @@ -import 'package:composite_calculator/calculators/lamina_engineering_constants_calculator.dart'; -import 'package:composite_calculator/models/lamina_engineering_constants_input.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('LaminaEngineeringConstantsCalculator Tests', () { - test('Default input test case', () { - // Arrange: Create input data with default values - var input = LaminaEngineeringConstantsInput.withDefaults(); - - // Act: Calculate the output using the calculator - var output = LaminaEngineeringConstantsCalculator.calculate(input); - - // Assert: Check the output against expected values (you will need to provide real expected values here) - expect(output.E1, closeTo(4431.314, 1e-3)); - expect(output.E2, closeTo(4431.314, 1e-3)); - expect(output.G12, closeTo(36144.578, 1e-3)); - expect(output.nu12, closeTo(0.77252, 1e-5)); - expect(output.eta1_12, closeTo(0.10339, 1e-5)); - expect(output.eta2_12, closeTo(0.10339, 1e-5)); - - // Optionally check the Q and S matrices for expected values - List> expectedQ = [ - [43000.503, 40500.503, -70422.535], - [40500.503, 43000.503, -70422.535], - [-70422.535, -70422.535, 154929.577] - ]; - - for (int i = 0; i < output.Q.length; i++) { - for (int j = 0; j < output.Q[i].length; j++) { - expect(output.Q[i][j], closeTo(expectedQ[i][j], 1e-3)); - } - } - }); - - test('Custom input test case', () { - // Arrange: Create custom input data - var input = LaminaEngineeringConstantsInput( - E1: 200000, E2: 12000, G12: 6000, nu12: 0.25, layupAngle: 30); - - // Act: Calculate the output using the calculator - var output = LaminaEngineeringConstantsCalculator.calculate(input); - - // Assert: Check if the output matches your expected results for custom input - // Assert: Check the output against expected values (you will need to provide real expected values here) - expect(output.E1, closeTo(7544.204322200394, 1e-3)); - expect(output.E2, closeTo(5823.475887170155, 1e-3)); - expect(output.G12, closeTo(17036.379769299012, 1e-3)); - expect(output.nu12, closeTo(0.8239685658153242, 1e-5)); - expect(output.eta1_12, closeTo(0.5982210844216282, 1e-5)); - expect(output.eta2_12, closeTo(-0.2642467565080819, 1e-5)); - - // Optionally check the Q and S matrices for expected values - List> expectedQ = [ - [115930.52070263491, 40656.68130489335, -125181.96189496155], - [40656.68130489335, 21576.693851944787, -38243.6600989902], - [-125181.96189496154, -38243.66009899021, 156581.55583437887] - ]; - - for (int i = 0; i < output.Q.length; i++) { - for (int j = 0; j < output.Q[i].length; j++) { - expect(output.Q[i][j], closeTo(expectedQ[i][j], 1e-3)); - } - } - }); - }); -} diff --git a/composite_calculator/test/lamina_stress_strain_calculator_tests.dart b/composite_calculator/test/lamina_stress_strain_calculator_tests.dart deleted file mode 100644 index f1b1a3e..0000000 --- a/composite_calculator/test/lamina_stress_strain_calculator_tests.dart +++ /dev/null @@ -1,79 +0,0 @@ -import 'package:composite_calculator/calculators/lamina_stress_strain_calculator.dart'; -import 'package:composite_calculator/models/lamina_stress_strain_input.dart'; -import 'package:composite_calculator/models/tensor_type.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('LaminaStressStrainCalculator Tests', () { - test('Default input test case', () { - // Arrange: Create input data with default values - var input = LaminaStressStrainInput.withDefaults(); - - // Act: Calculate the output using the calculator - var output = LaminaStressStrainCalculator.calculate(input); - - expect(output.epsilon11, closeTo(2.257 * 10e-5, 1e-3)); - expect(output.epsilon11, closeTo(-1.743 * 10e-5, 1e-3)); - expect(output.epsilon11, closeTo(2.333 * 10e-5, 1e-3)); - - // Optionally check the Q and S matrices for expected values - List> expectedQ = [ - [43000.503, 40500.503, -70422.535], - [40500.503, 43000.503, -70422.535], - [-70422.535, -70422.535, 154929.577] - ]; - - for (int i = 0; i < output.Q.length; i++) { - for (int j = 0; j < output.Q[i].length; j++) { - expect(output.Q[i][j], closeTo(expectedQ[i][j], 1e-3)); - } - } - }); - - test('Default input test case with custom strain input', () { - // Arrange: Create input data with default values - var input = LaminaStressStrainInput.withDefaults(); - input.tensorType = TensorType.strain; - input.epsilon11 = 1e-5; - - // Act: Calculate the output using the calculator - var output = LaminaStressStrainCalculator.calculate(input); - - expect(output.sigma11, closeTo(4.3e-1, 1e-3)); - expect(output.sigma22, closeTo(4.05e-1, 1e-3)); - expect(output.sigma12, closeTo(-7.042e-1, 1e-3)); - - // Optionally check the Q and S matrices for expected values - List> expectedQ = [ - [43000.503, 40500.503, -70422.535], - [40500.503, 43000.503, -70422.535], - [-70422.535, -70422.535, 154929.577] - ]; - - for (int i = 0; i < output.Q.length; i++) { - for (int j = 0; j < output.Q[i].length; j++) { - expect(output.Q[i][j], closeTo(expectedQ[i][j], 1e-3)); - } - } - }); - - test('Custom input test case', () { - // Arrange: Create custom input data - var input = LaminaStressStrainInput( - E1: 200000, - E2: 12000, - G12: 6000, - nu12: 0.25, - layupAngle: 30, - tensorType: TensorType.strain, - epsilon11: 1e-5); - - // Act: Calculate the output using the calculator - var output = LaminaStressStrainCalculator.calculate(input); - - expect(output.sigma11, closeTo(1.159, 1e-3)); - expect(output.sigma22, closeTo(4.066e-1, 1e-3)); - expect(output.sigma12, closeTo(-1.252, 1e-3)); - }); - }); -} diff --git a/composite_calculator/test/laminar_stress_strain_calculator_tests.dart b/composite_calculator/test/laminar_stress_strain_calculator_tests.dart deleted file mode 100644 index d52bfa8..0000000 --- a/composite_calculator/test/laminar_stress_strain_calculator_tests.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:composite_calculator/calculators/laminar_stress_strain_calculator.dart'; -import 'package:composite_calculator/models/laminar_stress_strain_input.dart'; -import 'package:composite_calculator/models/tensor_type.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('LaminarStressStrainCalculator Tests', () { - test('Default input test case', () { - // Arrange: Create input data with default values - var input = LaminarStressStrainInput.withDefaults(); - - // Act: Calculate the output using the calculator - var output = LaminarStressStrainCalculator.calculate(input); - - expect(output.epsilon11, closeTo(0.000017421124109966436, 1e-3)); - expect(output.epsilon22, closeTo(-0.000005445220495508603, 1e-3)); - expect(output.epsilon12, closeTo(4.712693325579657e-22, 1e-3)); - expect(output.kappa11, closeTo(3.261347510124405e-22, 1e-3)); - expect(output.kappa22, closeTo(-1.6068855629179688e-21, 1e-3)); - expect(output.kappa12, closeTo(2.184974840156989e-22, 1e-3)); - - }); - - test('Default input test case with custom strain input', () { - // Arrange: Create input data with default values - var input = LaminarStressStrainInput.withDefaults(); - input.tensorType = TensorType.strain; - input.epsilon11 = 1e-5; - - // Act: Calculate the output using the calculator - var output = LaminarStressStrainCalculator.calculate(input); - - expect(output.N11, closeTo(0.6361670020120725, 1e-3)); - expect(output.N22, closeTo(0.19884305835010055, 1e-3)); - expect(output.N12, closeTo(2.2638717237759187e-19, 1e-3)); - expect(output.M11, closeTo(0, 1e-3)); - expect(output.M22, closeTo(0, 1e-3)); - expect(output.M12, closeTo(0, 1e-3)); - }); - - }); -} diff --git a/composite_calculator/test/laminate_3d_properties_calculator_test.dart b/composite_calculator/test/laminate_3d_properties_calculator_test.dart deleted file mode 100644 index f82a901..0000000 --- a/composite_calculator/test/laminate_3d_properties_calculator_test.dart +++ /dev/null @@ -1,192 +0,0 @@ -import 'package:composite_calculator/calculators/laminate_3d_properties_calculator.dart'; -import 'package:composite_calculator/composite_calculator.dart'; -import 'package:composite_calculator/models/laminate_3d_properties_input.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('Laminate3DPropertiesCalculator Tests', () { - test('Default input test case', () { - // Arrange: Create input data with default values - var input = Laminate3DPropertiesInput.withDefaults(); - - // Act: Calculate the output using the calculator - var output = Laminate3DPropertiesCalculator.calculate(input); - - // Assert: - List> expectedStiffness = [ - [ - 64721.54471544715, - 20950.54200542005, - 3420.0542005420057, - 0.0, - 0.0, - 2.518159238084159e-14 - ], - [ - 20950.54200542005, - 64721.544715447155, - 3420.054200542005, - 0.0, - 0.0, - 1.968615053474552e-12 - ], - [ - 3420.054200542005, - 3420.054200542005, - 10775.067750677508, - 0.0, - 0.0, - 2.408436210670166e-14 - ], - [0.0, 0.0, 0.0, 4500.0, 1.4759469852271958e-14, 0.0], - [0.0, 0.0, 0.0, 1.475946985227196e-14, 4500.0, 0.0], - [ - 2.5181592380841582e-14, - 1.968615053474552e-12, - 2.4084362106701667e-14, - 0.0, - 0.0, - 21885.501355013548 - ] - ]; - - List> expectedCompliance = [ - [ - 1.7411039446147903e-05, - -5.43513583169007e-06, - -3.8012048192771085e-06, - 0.0, - 0.0, - 4.7304386328905965e-22 - ], - [ - -5.43513583169007e-06, - 1.7411039446147903e-05, - -3.8012048192771076e-06, - 0.0, - 0.0, - -1.555697483446916e-21 - ], - [ - -3.801204819277108e-06, - -3.801204819277108e-06, - 9.521987951807227e-05, - 0.0, - 0.0, - 2.415078035031392e-22 - ], - [0.0, 0.0, 0.0, 0.00022222222222222223, -7.2886270875417085e-22, 0.0], - [0.0, 0.0, 0.0, -7.288627087541709e-22, 0.00022222222222222223, 0.0], - [ - 4.730438632890597e-22, - -1.5556974834469162e-21, - 2.415078035031391e-22, - 0.0, - 0.0, - 4.569235055567595e-05 - ] - ]; - - for (int i = 0; i < output.stiffness.length; i++) { - for (int j = 0; j < output.stiffness[i].length; j++) { - expect( - output.stiffness[i][j], closeTo(expectedStiffness[i][j], 1e-3)); - } - } - for (int i = 0; i < output.compliance.length; i++) { - for (int j = 0; j < output.compliance[i].length; j++) { - expect( - output.compliance[i][j], closeTo(expectedCompliance[i][j], 1e-3)); - } - } - - expect( - output.engineeringConstants["E1"], closeTo(57434.824789926286, 1e-3)); - expect( - output.engineeringConstants["E2"], closeTo(57434.824789926286, 1e-3)); - expect( - output.engineeringConstants["E3"], closeTo(10502.008667320408, 1e-3)); - - expect(output.engineeringConstants["G12"], - closeTo(21885.501355013548, 1e-3)); - expect(output.engineeringConstants["G13"], closeTo(4500.0, 1e-3)); - expect(output.engineeringConstants["G23"], closeTo(4500.0, 1e-3)); - - expect(output.engineeringConstants["nu12"], - closeTo(0.3121660742025695, 1e-5)); - expect(output.engineeringConstants["nu13"], - closeTo(0.21832153278580413, 1e-5)); - expect(output.engineeringConstants["nu23"], - closeTo(0.21832153278580407, 1e-5)); - }); - - test('Custom input test case', () { - // Arrange: Create custom input data - var input = Laminate3DPropertiesInput( - analysisType: AnalysisType.thermalElastic, - E1: 200000, - E2: 10000, - G12: 5000, - nu12: 0.3, - nu23: 0.25, - layupSequence: "[0/90/45/-45]s", - layerThickness: 0.125, - alpha11: 0.1); - - // Act: Calculate the output using the calculator - var output = Laminate3DPropertiesCalculator.calculate(input); - - // Assert: - List> expectedStiffness = [ - [ - 83453.44129554657, - 27183.535762483127, - 3398.110661268555, - 0.0, - 0.0, - 2.5265570771882806e-14 - ], - [ - 27183.535762483127, - 83453.44129554652, - 3398.110661268555, - 0.0, - 0.0, - 3.2608622670156525e-12 - ], - [ - 3398.110661268555, - 3398.110661268555, - 10747.638326585693, - 0.0, - 0.0, - 2.4168340497742894e-14 - ], - [0.0, 0.0, 0.0, 4500.0, 1.4759469852271958e-14, 0.0], - [0.0, 0.0, 0.0, 1.475946985227196e-14, 4500.0, 0.0], - [ - 2.52655707718828e-14, - 3.2608622670156525e-12, - 2.4168340497742894e-14, - 0.0, - 0.0, - 28134.952766531715 - ] - ]; - - for (int i = 0; i < output.stiffness.length; i++) { - for (int j = 0; j < output.stiffness[i].length; j++) { - expect( - output.stiffness[i][j], closeTo(expectedStiffness[i][j], 1e-3)); - } - } - - expect( - output.engineeringConstants["alpha11"], closeTo(9.39815e-2, 1e-3)); - expect( - output.engineeringConstants["alpha22"], closeTo(9.39815e-2, 1e-3)); - expect( - output.engineeringConstants["alpha12"], closeTo(2.51097e-18, 1e-3)); - }); - }); -} diff --git a/composite_calculator/test/laminate_plate_properties_calculator_test.dart b/composite_calculator/test/laminate_plate_properties_calculator_test.dart deleted file mode 100644 index 0706ecf..0000000 --- a/composite_calculator/test/laminate_plate_properties_calculator_test.dart +++ /dev/null @@ -1,102 +0,0 @@ -import 'package:composite_calculator/calculators/lamina_engineering_constants_calculator.dart'; -import 'package:composite_calculator/calculators/laminate_plate_properties_calculator.dart'; -import 'package:composite_calculator/models/lamina_engineering_constants_input.dart'; -import 'package:composite_calculator/models/laminate_plate_properties_input.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('LaminatePlatePropertiesCalculator Tests', () { - test('Default input test case', () { - // Arrange: Create input data with default values - var input = LaminatePlatePropertiesInput.withDefaults(); - - // Act: Calculate the output using the calculator - var output = LaminatePlatePropertiesCalculator.calculate(input); - - // Assert: - List> expectedA = [ - [63616.70020120725, 19884.305835010055, 2.2638717237759177e-14], - [19884.305835010055, 63616.70020120723, 1.9648901387141773e-12], - [2.263871723775917e-14, 1.9648901387141773e-12, 21866.19718309859] - ]; - - List> expectedB = [ - [0.0, -1.1368683772161603e-13, 7.074599136799743e-15], - [ - -1.1368683772161603e-13, - -3.410605131648481e-13, - -1.2493627684232382e-13 - ], - [7.074599136799741e-15, -1.1249439120707794e-14, 0.0] - ]; - - List> expectedD = [ - [8006.057176391683, 602.8881623071763, 275.08802816901414], - [602.8881623071763, 4705.000838363513, 275.08802816901425], - [275.08802816901414, 275.0880281690143, 768.0457746478874] - ]; - - for (int i = 0; i < output.A.length; i++) { - for (int j = 0; j < output.A[i].length; j++) { - expect(output.A[i][j], closeTo(expectedA[i][j], 1e-3)); - } - } - for (int i = 0; i < output.B.length; i++) { - for (int j = 0; j < output.B[i].length; j++) { - expect(output.B[i][j], closeTo(expectedB[i][j], 1e-3)); - } - } - for (int i = 0; i < output.D.length; i++) { - for (int j = 0; j < output.D[i].length; j++) { - expect(output.D[i][j], closeTo(expectedD[i][j], 1e-3)); - } - } - - expect(output.inPlaneProperties.E1, closeTo(57401.57717078148, 1e-3)); - expect(output.inPlaneProperties.E2, closeTo(57401.57717078147, 1e-3)); - expect(output.inPlaneProperties.G12, closeTo(21866.19718309859, 1e-3)); - expect(output.inPlaneProperties.nu12, closeTo(0.312564244484858, 1e-5)); - expect(output.inPlaneProperties.eta121, - closeTo(-1.030486815205974e-17, 1e-5)); - expect(output.inPlaneProperties.eta122, - closeTo(3.410732216189378e-17, 1e-5)); - - expect(output.flexuralProperties.E1, closeTo(94227.69205595773, 1e-3)); - expect(output.flexuralProperties.E2, closeTo(54891.6513180624, 1e-3)); - expect(output.flexuralProperties.G12, closeTo(8936.487112074954, 1e-3)); - expect( - output.flexuralProperties.nu12, closeTo(0.10948959541430607, 1e-5)); - expect( - output.flexuralProperties.eta121, closeTo(0.03024905861937437, 1e-5)); - expect(output.flexuralProperties.eta122, - closeTo(0.054591112229385966, 1e-5)); - }); - - test('Custom input test case', () { - // Arrange: Create custom input data - var input = LaminatePlatePropertiesInput( - E1: 200000, - E2: 10000, - G12: 5000, - nu12: 0.3, - layupSequence: "[0/90/45/-45]s", - layerThickness: 0.125); - - // Act: Calculate the output using the calculator - var output = LaminatePlatePropertiesCalculator.calculate(input); - - // Assert: - List> expectedA = [ - [82359.36715218483, 26128.8297338021, 2.271993528051501e-14], - [26128.8297338021, 82359.3671521848, 3.2571113306334796e-12], - [2.2719935280515002e-14, 3.2571113306334796e-12, 28115.268709191358] - ]; - - for (int i = 0; i < output.A.length; i++) { - for (int j = 0; j < output.A[i].length; j++) { - expect(output.A[i][j], closeTo(expectedA[i][j], 1e-3)); - } - } - }); - }); -} diff --git a/domain/lib/usecases/chat_usecase.dart b/domain/lib/usecases/chat_usecase.dart index f9aae57..8cc4c14 100644 --- a/domain/lib/usecases/chat_usecase.dart +++ b/domain/lib/usecases/chat_usecase.dart @@ -1,5 +1,3 @@ -import 'package:composite_calculator/models/lamina_engineering_constants_input.dart'; - import '../entities/function_tool.dart'; import '../entities/message.dart'; import '../repositories_abstract/chat_repository.dart'; diff --git a/domain/pubspec.yaml b/domain/pubspec.yaml index 5dd5910..e53f75a 100644 --- a/domain/pubspec.yaml +++ b/domain/pubspec.yaml @@ -10,8 +10,6 @@ environment: dependencies: flutter: sdk: flutter - composite_calculator: - path: ../composite_calculator dev_dependencies: flutter_test: diff --git a/firebase.json b/firebase.json index 0d25a77..fa1973b 100644 --- a/firebase.json +++ b/firebase.json @@ -3,7 +3,6 @@ "public": "build/web", "ignore": [ "firebase.json", - "**/.*", "**/node_modules/**" ] } diff --git a/lib/presentation/chat/views/markdown_with_math.dart b/lib/presentation/chat/views/markdown_with_math.dart index 7456f2c..9637927 100644 --- a/lib/presentation/chat/views/markdown_with_math.dart +++ b/lib/presentation/chat/views/markdown_with_math.dart @@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:flutter_math_fork/flutter_math.dart'; import 'package:markdown/markdown.dart' as md; +import 'package:flutter/foundation.dart'; class MarkdownWithMath extends StatelessWidget { final String markdownData; @@ -12,15 +13,27 @@ class MarkdownWithMath extends StatelessWidget { @override Widget build(BuildContext context) { - return MarkdownBody( - data: markdownData, - selectable: true, - // For better user experience - builders: {'h5': InlineMathBuilder(), 'h5': NewlineMathBuilder()}, - inlineSyntaxes: [MathNewlineSyntax(), MathInlineSyntax()], - // Custom inline syntax for inline math - styleSheet: MarkdownStyleSheet(), - ); + if (kIsWeb) { + return MarkdownBody( + data: markdownData, + selectable: true, + // For better user experience + builders: {'h5': NewlineMathBuilder()}, + inlineSyntaxes: [MathNewlineSyntax()], + // Custom inline syntax for inline math + styleSheet: MarkdownStyleSheet(), + ); + } else { + return MarkdownBody( + data: markdownData, + selectable: true, + // For better user experience + builders: {'h5': InlineMathBuilder(), 'h5': NewlineMathBuilder()}, + inlineSyntaxes: [MathNewlineSyntax(), MathInlineSyntax()], + // Custom inline syntax for inline math + styleSheet: MarkdownStyleSheet(), + ); + } } } diff --git a/pubspec.lock b/pubspec.lock index 5213408..8b74256 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -212,10 +212,11 @@ packages: composite_calculator: dependency: "direct main" description: - path: composite_calculator - relative: true - source: path - version: "0.0.1" + name: composite_calculator + sha256: "8666498a8b8f2e52325e70c281767b1e7cce593aaa74bbb194c877900877cb19" + url: "https://pub.dev" + source: hosted + version: "1.0.0" convert: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cfec4b6..bb331d9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,9 +22,8 @@ dependencies: path: domain data: path: data - composite_calculator: - path: composite_calculator + composite_calculator: ^1.0.0 cupertino_icons: ^1.0.8 fl_chart: ^0.40.2 app_tracking_transparency: ^2.0.6